我遇到了结构问题。在每个函数声明之前,我会收到有关标识符的错误。 '类型定义', 'COORDS stackCreate' 之前的错误发生, 'COORDS stackPush'预期标识符 - C
typedef struct coords * coordPtr
{
int x = -1;
int y = -1;
struct coords * next;
};
coords stackCreate(int x, int y){
coordPtr stack = malloc(sizeof(coords));
stack->x = x;
stack->y = y;
return stack;
}
coords stackPush(int x, int y, coords stack){
stack->next = malloc(sizeof(coords));
stack->next->x = x;
stack->next->y = y;
}
感谢您的帮助!
好了,你有'typedef结构COORDS * coordPtr' ---这绝对不是正确的C. – 2015-02-11 20:35:30
你尝试过: typedef结构_coords { int x = -1; int y = -1; struct _coords * next; } coords; – madz 2015-02-11 20:36:53
这是对C语法的一个简单误解:'* coordPtr'在结构体之后,而不是在它之前。投票结束为错字。 – dasblinkenlight 2015-02-11 20:36:58