so all i want is to get this to display the ascii 2 table using an unsigned char array. heres what i have and whats not working:
unsigned char digits[100];
int i=0;
while (i<=100)
{
printf("\n%c",digits[i]+48);
i++;
}
pretty simple code so far. not working at all though.
any suggestions?
The problem is that digits[i]
is not initialized.
If all you're doing is displaying the ASCII table, you don't need the array at all.
There is no need to use an array. This will work:
int i=0;
while (i<=100){
printf("\n%c", i + '0');
i++;
}
Also, your array is not initialized.
#include <stdio.h>
int main(void){
unsigned char digits[100] = { 1,0,2,4 };
int i=0;
while (i<100){
printf("\n%c",digits[i++]+'0');
}
printf("\ninput number:");
fgets(digits, 100, stdin);
i=0;
while(digits[i] && digits[i] != '\n')
printf("\n%c", digits[i++]);
return 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.