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然后添加不能找出原因
答案 0 :(得分:6)
cst1
和cst2
似乎没有以NULL结尾。
char cst1[] = {info[x+2], info[x+3], '\0'};
char cst2[] = {info[x+5], info[x+6], '\0'};