[英]C, get unsigned char to use ascii 2 table
so all i want is to get this to display the ascii 2 table using an unsigned char array. 所以我想要的是使用unsigned char数组来显示ascii 2表。 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. 问题是
digits[i]
没有初始化。
If all you're doing is displaying the ASCII table, you don't need the array at all. 如果您所做的只是显示ASCII表,则根本不需要该数组。
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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.