我正在尝试编译此代码(将模拟 Langton 的 Ant):
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct
{
unsigned short x, y;
enum directions {up = 0, right, down, left} direction;
} langtonsAnt;
void turnAnt (lantonsAnt *pant, unsigned short quarterTurns)
{
pant->direction = (pant->direction + quarterTurns) % 4;
}
int main ()
{
return EXIT_SUCCESS;
}
但是,我不断收到此错误:
12|error: expected ')' before '*' token|
编译器是gcc。
我无法弄清楚哪里出了问题,因为我已经搜索了网络和各种引用资料。
附言不要担心 header ,程序的其他地方需要这些 header 。
最佳答案
void turnAnt (lantonsAnt *pant, unsigned short quarterTurns)
应该是
void turnAnt (langtonsAnt *pant, unsigned short quarterTurns)
关于c - 指向 C 中的结构 - 错误 : expected ')' before '*' token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8774456/