#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int info;
struct node* next;
}Node;
typedef Node* list;
void printlist(list n)
{
while(n!=NULL)
{
printf("%d ",n->info);
n=n->next;
}
}
int main()
{
printf("Hello world!\n");
list head,temp;
char ch;
head=NULL;
printf("Want to add data:\n");
scanf("%c",&ch);
while(ch=='y'||ch=='Y')
{
temp=(list)malloc(sizeof(Node));
scanf("%d",&temp->info);
temp->next=head;
head=temp->next;
printf("Want to add more data:\n");
scanf("%c",&ch);
}
printlist(head);
return 0;
}
this is my code. my problem is here that I cannot and data in my list but the node is added ... I think there is something wrong in my "scanf" function.... please help me to solve this problem and send me the corrected code
thank u...hope I can get a reply soon