I don't know where is the problem, the output is infinite number of 10 !!!! Help is very much appreciated.Code:#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
int data;
struct Node *next;
}node;
void insert(node **ptrtohead, int val)
{
node *temp=(node*)malloc(sizeof(node));
*ptrtohead=temp;
temp->data=val;
temp->next=NULL;
if(*ptrtohead != NULL)
{
temp->next=*ptrtohead;
*ptrtohead=temp;
}
}
void display(node *start)
{
while(start!=NULL)
{
printf("%d ",start->data);
start= start->next;
}
}
int main(int argc, char *argv[])
{
node *head=NULL;
insert(&head,10);
insert(&head,20);
display(head);
system("PAUSE");
return 0;
}