Here is my Code. A Simple FILO Linked List but the error i'm getting is weird. its on the Insert Function where i declare temp, saying Node is undeclared. Don't understand how Ive done this like 10 times and no errors. Thank you for your time.
//Linked List: Inserting a node at the beginning (FILO)
#include <stdio.h>
#include <stdlib.h>
struct Node{
int data;
struct Node* next;
};
struct Node* head; //Global
void Insert (int x)
{
struct Node* temp = (Node*) malloc(sizeof(struct Node));
temp->data = x;
temp->next = head;
head = temp;
}
void Print()
{
struct Node* temp = head; //We use a temporary because we dont want to lose the reference to the head
printf ("List is: ");
while(temp != NULL)
{
printf (" %d", temp->data);
temp = temp -> next;
}
printf ("\n");
}
int main(){
head = NULL; //empty list
int n,i,x;
printf ("How many numbers?\n");
scanf ("%d",&n);
for (i=0; i<n; i++)
{
printf ("Enter the Number\n");
scanf ("%d",&x);
Insert(x);
Print();
}
}