我知道我会比这更好。
但是每次我运行数组而不是从1到5开始时,它都从49开始。我不知道为什么,但是这开始变得令人讨厌。
我敢肯定这很简单,但我现在不知道如何。我想做的是运行foreach循环并打印出数组的该部分。
然后,我想测试Status []。
仅当条件合适时,状态才应打印测试编号。testnum = arr [i]
int main(void)
{
char status[10];
int test1 = 0, test2 = 0, test3 = 0, test4 = 0;
int arr[] = {'1','2','3','4','5'};
int value[] = { '1','2','3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25'};
for (int i = 0; i < 5; i++)
{
printf(" \n %i# %i \n", i, arr[i]);
}
printf("test S: %i \n", test1);
printf("test MS: %i \n", test2);
printf("test MJ: %i \n", test3);
printf("test SH: %i \n", test4);
system("pause");
}
更新:抱歉是要说我读错了。它不是读写1 2 3 4 5,而是显示49 50,依此类推
该字符的值'1'
在您的系统上显示为49。数字字符在解释50的任何编码中是连续的,等等。
也许您的意思是: int arr[] = {1,2,3,4,5};
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句