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

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

发生意外错误,请帮助解决

/*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 分配内存。不要忘记检查 return 值以检查是否成功分配内存。

还有这里

if (temp1 ==1)

您将指针与 int 进行比较。这是错误的。我不知道你想在这里做什么...