[英]Pointing to struct in C - error: expected ')' before '*' token
I am trying to compile this code (gonna be a simulation of Langton's 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;
}
However, I keep getting this error: 但是,我不断收到此错误:
12|error: expected ')' before '*' token|
12 |错误:预期在'*'标记之前的')'|
The compiler is gcc. 编译器是gcc。
I cannot figure out what's wrong as I already searched the web and various references. 我已经搜索了网络和各种参考文献,因此无法弄清出什么问题了。
PS Don't worry about the headers, those are needed elsewhere in the program. PS不用担心标题,程序中其他地方都需要这些标题。
void turnAnt (lantonsAnt *pant, unsigned short quarterTurns)
应该
void turnAnt (langtonsAnt *pant, unsigned short quarterTurns)
You are missing a 'g' in your passed pointer to the function turnAnt! 您在指向函数turnAnt的传递指针中缺少“ g”! Notice the 'g' after "lan" in the struct name?
注意结构名称中“ lan”之后的“ g”吗?
typedef struct
{
unsigned short x, y;
enum directions {up = 0, right, down, left} direction;
} langtonsAnt;
But then in your function turnAnt, " lantonsAnt *pant " is missing the 'g'! 但是在您的函数turnAnt中,“ lantonsAnt * pant”缺少了“ g”! It should look like this:
它看起来应该像这样:
void turnAnt (langtonsAnt *pant, unsigned short quarterTurns)
{
......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.