Tuesday, 13 March 2012

problem from prnBits

void prnBits(unsigned int val){
  for(int i = sizeof(unsigned int)*8-1; i>=0;printf("%d", !!(val & (1<<i--))));
}



I’m confused about the "sizeof (unsigned int) * 8 -1".........Why should multiplied by 8....

Monday, 12 March 2012

How is works.....Walkthrough w4

const char *  w4(float val, char ch){
   static char bar[81];
   int i;
   for(i = 0; i<val && i<80;i++){
        bar[i] = ch;
}
bar[i] = 0;
return bar;
}