我用C语言编码,无法找出错误是什么.它一直告诉我第一:在这一行
temp = (Node*) malloc(sizeof(struct Node));
Run Code Online (Sandbox Code Playgroud)
的Node是不宣而第一次使用是在这个function.but我想我以前已经声明它.
第二:在同一行
"预期表达''''令牌"
它指向了 (Node*)
第三:
"投入结束时的预期声明或声明."
而它指向}主要关闭.
对于第一个我搜索并发现它是因为C89而且我必须在我的函数顶部声明所有变量.我做了但是错误仍然存在.
这是我的代码:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
struct Node{
int data;
struct Node* next;
};
struct Node* head;
void Add(int x){
struct Node* temp;
temp = (Node*) malloc(sizeof(struct Node));
temp -> data = x;
temp -> next = head;
head = temp;
}
void print(){
struct Node* temp;
temp = head;
printf("List is:");
while(temp != NULL){
printf(" %s",temp -> …Run Code Online (Sandbox Code Playgroud)