Possible Duplicate:
Can I use a binary literal in C or C++?
I cannot display the results of bitwise operators in C. In the code below, a&b should be 100001 and a|b 111111. However, the printed results are different. I tried to do this with and without itoa, but to no avail. Why doesn't the program print the answers correctly?
#include<stdio.h>
#include<stdlib.h>
int main (int argc, char* argv[]) {
unsigned a = 101101;
unsigned b = 110011;
unsigned c = a&b;
unsigned d = a|b;
char s[100];
char t[100];
itoa(c,s,2);
itoa(d,t,2);
printf("%s\n",s); /* Shouldn't it produce 100001?
Instead I get 11000100010101001*/
printf("%s\n",t); /* Ought to print 111111.
Instead it prints 11010111111111111 */
return 0;
}
Thank You