#include <stdio.h>
#include <stdlib.h>
struct node{
int data;
struct node* next;}*ptr,*head=NULL;
char ch;
void create()
{
printf("\nEnter the value");
scanf("%d",&ptr->data);
if(head==NULL)
{
head=ptr;
ptr=head->next;
}
else
ptr=ptr->next;
printf("\nadd another node\n");
scanf(" %c",&ch);
if(ch==‘y’)
create();
return;
}
void print()
{
system(“cls”);
ptr=head;
while(ptr!=NULL)
{
printf("%d ",ptr->data);
ptr=ptr->next;
}
return;
}
int main(){
ptr=(struct node*)malloc(sizeof(struct node));
create();
print();
return 0;
}
The above code is not running in codeblocks. Please point out my mistake.