C 缺少“;”在“类型”之前

C 缺少“;”在“类型”之前,c,C,改为: int main() { node *head; head = createList(); void printList(node *head); // This isn't how you call a function return 0; } 这一行主要是你的问题: int main() { node *head; head = createList(); printList(head); // This is. re

改为:

int main()
{
    node *head;
    head = createList();
    void printList(node *head); // This isn't how you call a function
    return 0;
}
这一行主要是你的问题:

int main()
{
    node *head;
    head = createList();
    printList(head); // This is.
    return 0;
}
应该是:

void printList(node *head);

您希望在那里调用函数,而不是试图声明它。

错误消息指的是哪一行?错误C2143:语法错误:缺少“;”在'type'>>>之前作废printListnode头;错误C2143:语法错误:缺少'{'before'&错误C2371:'createList':重新定义;不同的基本类型>>>node*createList这是程序员的错误,但不应该导致编译器错误。void printListnode*head;这不应该被视为声明吗?为什么会导致任何问题?@Oli Charlesworth:使用VS2008编译为C会出现此错误-CompILL作为C++没有。@ OLI是C中的编译错误,因为声明必须在函数体中的任何其他东西之前出现。@戴维:是的,我应该在GCC中启用-迂回的…
int main()
{
    node *head;
    head = createList();
    printList(head); // This is.
    return 0;
}
void printList(node *head);
printList(head);