Hi all!
I'm new to linked lists. I hope the beginning of the code is OK. In any case the end of the code is wrong according to the compiler.
Thanks in advance for help.Code:#include <stdio.h>
#include <stdlib.h>
char string[10];
struct node
{
char *word;
struct node *next;
};
int main(void)
{
struct node *Head=NULL;
Head = malloc( sizeof(struct node));
struct node *root=NULL;
Head->next = root;
while(string[0] !='q')
{
printf("\nInput string:\n");
scanf("%s", string);
root = malloc( sizeof(struct node));
root->word = string;
root->next = root;
}
printf("\nHere is the list:\n");
struct node* current = Head;
while (current != NULL)
{
printf(" %s\n"),word;
current = current->next;
}
struct node* current = Head;
while (current != NULL)
{
free(node*);
current = current->next;
}
return 0;
}