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|
The compiler is 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.
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! Notice the 'g' after "lan" in the struct name?
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'! It should look like this:
void turnAnt (langtonsAnt *pant, unsigned short quarterTurns)
{
......
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.