问题描述
大小被定义为 15,但是这个程序由于某种原因只运行了 8 次,我不知道为什么。 这部分是唯一的问题。一旦我删除它并用不使用 ctime 的东西替换它,它就运行了 15 次。
for(int count = 0; count < size; count++)
{
printf("Plane ID : %d\n",planes[count].planeid);
printf("Destination : %s\n",planes[count].destination);
char * time_str;
time_str = ctime(&planes[count].time);
printf("Depart Time/Date : %s \n",time_str);
count++;
}
解决方法
每次循环将计数增加两次:
for (int count = 0; count < size; count++)
// ^^^^^^^ HERE
{
..
count++; // HERE
}
删除函数体末尾的第二个 count++;
。