Binary Conversion & Palindrome Check Function

Hi everyone. I don't really have access to a compiler or IDE right now, so I haven't tested it yet, but it looks like it would run okay.
My job is to check if a decimal number is a palindrome in binary.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
int nDec;
int nTemp = nDec; //nTemp is a placeholder

//obtain number of bits in answer
//by finding number of divisions by 2
for(int n=0;nTemp!=0;n++)
{
  nTemp = nTemp / 2;
}

nTemp = nDec;
const int t = n;
bool abRem[t] = 0;
bool abReverse[t] = 0;

//actual conversion and comparison
for(int iii=t-1;nTemp!=0;iii--)
{
  abRem[iii] = nTemp % 2;
  abReverse[t-m-1] = anRem[iii]
  nTemp = nTemp / 2;
}

for(int jjj = 0;jjj<t;jjj++)
{
  bool bSame = 0;
  if(abRem[jjj]==abRev[jjj])
    bSame = 1;
}
//code ends with an if statement to print
//nDec is a binary palindrome if bSame = 1 

NB: just a code snippet, so I skipped the #include, couts and others.
Can anyone help me find any errors? Did I do a dangerous thing by storing the binary in an array, or by making the array boolean?
I don't really have access to a compiler or IDE right now
http://ideone.com/
http://coliru.stacked-crooked.com/
http://melpon.org/wandbox/
http://cpp.sh/
Last edited on
Thanks! I finally ran it on ideone.com and I kept getting an error until I declared int m before the for-loop. It works!
Topic archived. No new replies allowed.