Why am I getting this error?
C:\Program Files\Miracle C\queue_insert.c: line 3: Parse Error, expecting `'{''
'struct node'
aborting compile
This is the code I don't see the problem with it.
#include <stdio.h>
struct node;
struct node
{
char value;
node *next;
};
node *head=NULL, *tail=NULL;
void addNode(char);
void printList();
void main()
{
char input;
printf("Enter you name:\n");
input = getchar();
while( input != '\n' )
{
addNode( input );
input = getchar();
}
printf("\nYou have entered: ");
printList();
printf("\n\nProgram complete\n");
}
void addNode( char val )
{
node *insert;
insert = new node;
insert->value = val;
insert->next = NULL;
if( head == NULL ) //if the list is empty
head = tail = insert;
else
{
tail->next = insert;
tail = insert;
}
}
void printList()
{
node *p = head;
while( p != NULL )
{
printf("%c", p->value );
p = p->next;
}
}