for 循环的编译器错误
Compiler errors on for loop
错误如下:
main.c|188|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
main.c|195|error: expected expression before '}' token|
main.c|195|error: expected expression before '}' token|
main.c|195|error: expected expression before '}' token|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
这是我的代码中出现它们的部分,以及相应的行号:
(我在 Codeblocks 上编译这个)
//If Option 4 is selected
if (input == 4) {
printf("You selected Option 4: Display all courses.\n");
for (int counter = 0, counter < 560000, counter++) { //line 188
course ToDisplay;
fread(&ToDisplay, sizeof(course), 1, in_file);
if (ToDisplay.dept != 000 && ToDisplay.num != 000) {
printf("%2s.%d.%d %d.%d ", ToDisplay.div, ToDisplay.dept, ToDisplay.num, ToDisplay.credits, ToDisplay.title);`
}
}
} //line 195
在语句中使用分号而不是逗号
for (int counter = 0, counter < 560000, counter++) { //line 188
^^ ^^
否则编译器认为记录
int counter = 0, counter < 560000, counter++
作为多个变量的声明(同名)
错误如下:
main.c|188|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
main.c|195|error: expected expression before '}' token|
main.c|195|error: expected expression before '}' token|
main.c|195|error: expected expression before '}' token|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
这是我的代码中出现它们的部分,以及相应的行号: (我在 Codeblocks 上编译这个)
//If Option 4 is selected
if (input == 4) {
printf("You selected Option 4: Display all courses.\n");
for (int counter = 0, counter < 560000, counter++) { //line 188
course ToDisplay;
fread(&ToDisplay, sizeof(course), 1, in_file);
if (ToDisplay.dept != 000 && ToDisplay.num != 000) {
printf("%2s.%d.%d %d.%d ", ToDisplay.div, ToDisplay.dept, ToDisplay.num, ToDisplay.credits, ToDisplay.title);`
}
}
} //line 195
在语句中使用分号而不是逗号
for (int counter = 0, counter < 560000, counter++) { //line 188
^^ ^^
否则编译器认为记录
int counter = 0, counter < 560000, counter++
作为多个变量的声明(同名)