c - Having trouble finding what is causing this error -
i trying create program output binary code 16 numbers. here have far:
#include <stdio.h> #include <stdlib.h> int i; int count; int mask; int = 0xf5a2; int mask = 0x8000; int main() { printf("hex value= %x binary= \n", i); { (count=0; count<15; count++1) { if (i&mask) printf("1\n"); else printf("0\n"); } (mask = mask>>1); } return 0; } the error:
|16|error: expected ')' before numeric constant| also let me know if have other mistakes, in advance!
the error referring expression:
count++1 which makes no sense.
i assume want:
count++ making line
for (count=0; count<15; count++) you have other strangeness in code such as:
int i; // declare integer named "i" int mask; // declare integer named "mask" int = 0xf5a2; // declare integer named "i". did forget first one??? int mask = 0x8000; // did forget declared integer named "mask"? printf("hex value= %x binary= \n", i); { [...] } // why did put bracket-scope under printf call? // scopes typically follow loops , if-statements! (mask = mask>>1); // why put parens around plain-old expression?? after fixing weirdness in code, should like:
#include <stdio.h> #include <stdlib.h> int main() { int = 0xf5a2; int mask = 0x8000; printf("hex value= %x binary= \n", i); (int count=0; count<15; ++count, mask>>=1) { printf("%d\n", (i&mask)? 1 : 0); } return 0; }
Comments
Post a Comment