错误:'';C编程中的预期值(得到“10”)
在我问这个问题之前,我已经调试了好几个小时,并且读了类似的问题帖子,但我仍然无法解决这个问题。我检查了在定义void drop(int size,int x_coor,int y_coor,int grid)这个方法时是否发生了错误。如何修复这个错误 这就是错误: main.c:11:错误:','应为(得到“10”)错误:'';C编程中的预期值(得到“10”),c,C,在我问这个问题之前,我已经调试了好几个小时,并且读了类似的问题帖子,但我仍然无法解决这个问题。我检查了在定义void drop(int size,int x_coor,int y_coor,int grid)这个方法时是否发生了错误。如何修复这个错误 这就是错误: main.c:11:错误:','应为(得到“10”) #包括 #包括 const int max_height=4; 内部高度; #定义尺寸10 整数网格[大小][大小]; 空位下降(整数大小、整数x_________________
#包括
#包括
const int max_height=4;
内部高度;
#定义尺寸10
整数网格[大小][大小];
空位下降(整数大小、整数x_________________________________;
int是稳定的(int grid[size][size]);
无效显示(整数网格[大小][大小]);
/*
函数以给定桩数打印23*23网格
*/
void create_InitialGrid(int total_param,char*piles[])
{
int i,j,k,赋值;
对于(i=0;i
我刚刚尝试编译您的代码,#define size
宏似乎与drop
函数中的int size
参数冲突
以下是我的Mac电脑上的gcc
的输出:
temp.c:11:15: error: expected ')'
void drop(int size, int x_coor, int y_coor, int grid);
^
temp.c:8:14: note: expanded from macro 'size'
#define size 10
^
temp.c:11:10: note: to match this '('
void drop(int size, int x_coor, int y_coor, int grid);
^
希望能解决它!:) 我刚刚尝试编译您的代码,
#define size
宏似乎与drop
函数中的int size
参数冲突
以下是我的Mac电脑上的gcc
的输出:
temp.c:11:15: error: expected ')'
void drop(int size, int x_coor, int y_coor, int grid);
^
temp.c:8:14: note: expanded from macro 'size'
#define size 10
^
temp.c:11:10: note: to match this '('
void drop(int size, int x_coor, int y_coor, int grid);
^
希望能解决它!:)
它正在转变为
void drop(int 10, int x_coor, int y_coor, int grid);
在编译器预处理步骤之后,如您所定义的#定义大小10
你应该申报为
void drop(int , int , int , int );
或者在函数声明中为该变量使用不同的名称
它正在转变为
void drop(int 10, int x_coor, int y_coor, int grid);
在编译器预处理步骤之后,如您所定义的#定义大小10
你应该申报为
void drop(int , int , int , int );
或者在函数声明中为该变量使用不同的名称不要使用宏。@o11c不幸的是,在C中没有太多的选择。不能为声明数组声明常量sizes@user7027796这就是为什么在大多数约定中,常量都是大写的。如果编写
SIZE
,则不会出现此问题。无论如何,避免使用像这样的通用词,并使用描述性名称,如GRID\u SIZE
。而@LưuVĩnhPhúc只有3个数字:0、1和批次。@o11c我不明白你的意思。尝试const int SIZE=10;int grid[SIZE][SIZE]
不要使用宏。@o11c不幸的是,在C语言中没有太多的选择。不能为声明数组声明常量sizes@user7027796这就是为什么在大多数约定中,常量都是大写的。如果编写SIZE
,则不会出现此问题。无论如何,避免使用像这样的通用词,并使用描述性名称,如GRID\u SIZE
。而@LưuVĩnhPhúc只有3个数字:0、1和批次。@o11c我不明白你的意思。尝试const int SIZE=10;int grid[SIZE][SIZE]
感谢您的帮助。我更改了命名,现在已修复,但存在另一个运行时错误:应为指针。感谢您的帮助。我更改了命名,现在已修复,但存在另一个运行时错误:应为指针。