我在我的 C 代码中遇到了这个错误:
error:called object type int is not a function or function pointer
我到处寻找答案,我检查过的所有地方都确认这段代码应该有效,那么我错过了什么?我想将随机数分配给两个不同的变量。我已经注释掉了我在 IDE 中遇到的错误。 (注意:这不是完整代码,只是相关部分)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
int k, seed, mines, row, column, boom;
int board[9][10];
printf("Please enter your seed: ");
scanf("%d", &seed); getchar();
srand(seed);
for(k = 1; k <= mines; k++) {
row = rand() % 8; // error:called object type int is not a function or function pointer
column = rand() % 8; // error:called object type int is not a function or function pointer
if(board[row][column] == 0) {
board[row][column] = boom;
}
}
}
int k; seed; mines; row; column;
按如下方式更正上面的行:
int k, seed, mines, row, column;
我是一名优秀的程序员,十分优秀!