编译错误:solution.c:20:5: Error:期望的标识符或'('在' {' token{之前

Compilation Error: solution.c:20:5: error: expected identifier or ‘(’ before ‘{’ token {

本文关键字:之前 token solution 错误 编译 期望 Error 标识符      更新时间:2023-10-16

出现意外错误,请帮助解决

/*Program to delete the nth Node from the Linked List*/

见这里的代码片段:

http://pastebin.com/esgv41aC

您忘记在这里添加struct的名称了:

struct{
    int data;
    struct Node* next;
};

应该是

struct Node {
    int data;
    struct Node* next;
};

另一个问题是您使用new,这是一个c++操作符来分配内存。在C语言中,使用malloccalloc来分配内存。不要忘记检查返回值,以检查是否成功分配内存。

这里

,

if (temp1 ==1)

将指针与int比较。这是错误的。我不知道你到底想干什么