c - 错误 : called object type int is not a function or function pointer

标签 c random

我在我的 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;

关于c - 错误 : called object type int is not a function or function pointer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30825390/

相关文章:

java - 如何在具有随机大小和随机坐标的画圆内绘制字母?

java - 获取大于system.currentTimeMillis值的rand值的方法

c++ - 为什么 system() 失败并显示错误代码 127?

c - 将登录信息与套接字相关联?

python - 在 C 中调用 Python-3 函数

c - 在 C 中使用递归反转数字函数

c - 如何将所有命令行参数连接在一起并打印出结果值?

haskell - 如何在 Haskell 函数中将随机数用作 Double ?

java - 使用 Java 从 MongoDB 获取随机文档/记录

python - 如何将字符串散列为 [0 :1]? 中的 float