3
for(int y = 0; y < 5; y++)
{   
   char cst1[2] = {info[x+2], info[x+3]};
   char cst2[2] = {info[x+5], info[x+6]};
   sales[count][atoi(&info[x]) - 1] = atoi(cst1) + atoi(cst2);
   x += 8;
}

每次我执行以下代码时, atoi(cst1) 值乘以 2 然后相加, atoi(cst2) 乘以 100 然后相加 不知道为什么

4

1 回答 1

6

cst1并且cst2似乎没有以 NUL 结尾。

char cst1[] = {info[x+2], info[x+3], '\0'};
char cst2[] = {info[x+5], info[x+6], '\0'};
于 2012-12-15T05:19:53.063 回答