1

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.

P.S. Don't worry about the headers, those are needed elsewhere in the program.

2
  • 6
    lantonsAnt -> langtonsAnt?
    – marko
    Jan 8, 2012 at 0:53
  • Line 10: langtosAnt. Line 12: lantosAnt. Note the missing g...
    – fge
    Jan 8, 2012 at 0:56

2 Answers 2

7
void turnAnt (lantonsAnt *pant, unsigned short quarterTurns)

should be

void turnAnt (langtonsAnt *pant, unsigned short quarterTurns)
3

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)
{
    ......

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.