I wanted to create a simple table by printing lines in between my values with a header at the top and my numbers left justified. However, when I get to a ten digit number or larger, my code seems to break and my count variable goes to zero as far as I can tell, causing a bunch of space to be printed where it doesn't need to be. I was wondering what I'm doing wrong. Thank you for any help you can offer!
#include <stdio.h>
int main ( int argc, char *argv[] ) {
unsigned int y = 1;
int x = 1;
int limit = sizeof(int) * 8;
int z, n, m, count;
printf("| x | y | \n");
for(z = 0; z < limit - 1; z++){
x = x << 1;
y = y << 1;
m = x;
count = 0;
while(m > 0){
m = m / 10;
count++;
}
printf("|%d", x);
for(n = 11; n >= count; n--)
printf(" ");
printf("|%u", y);
for(n = 11; n >= count; n--)
printf(" ");
printf("|\n");
return 0 ;
}