[courses] [C] Finally get lesson 10 exc #2 (without understanding your bit-shift)
anca14 at anca14.ro
anca14 at anca14.ro
Wed Nov 13 17:33:29 EST 2002
>
> #define BITS 32
>
you should use
#define BITS sizeof(int) * 8
> while(i > 0) {
> if(i == BITS - 8 || i == BITS - 16 || i == BITS
-
> 24) {
> /* Is there an easier way to do the line above? */
> printf(" ");
> }
> printf("0");
> i--;
> }
#define D_EIGHT(x) if (remainder(x,8)==0) printf(" ");
to use reminder you'll need to include math.h header.
[...]
while (i > 0)
{
D_EIGHT(i);
printf("0");
cout--;
}
More information about the Courses
mailing list