c - 指向 C 中的结构 - 错误 : expected ')' before '*' token

标签 c gcc compiler-errors

我正在尝试编译此代码(将模拟 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/

相关文章:

C程序从用户那里获取联系并将其添加到文件中

c - free() 是否将内存归零?

c - 如何检测预处理器中的 X32 ABI 或环境?

c - 通过 MacPorts 安装 gcc45 后,如何使用它在我的 Mac 上构建 C 语言?

c++ - 如何修复C++中的 “expected”错误

c++ - 标准库和GCC的CLion链接器错误

c - 从链表中递归删除数字

c - gcc 未使用/读取 LIBRARY_PATH 环境变量

visual-c++ - 警告MSB8012 : TargetPath(C:\wxWidgets-2.9.1\build\wx291_msw_vc10\..\..\lib\vc_lib\wxregex.lib) does not match

c - 如果我声明一个 char 数组,我是否也必须计算空字符?