There are two problems I can see here:
1. Your last print call inside the
print()
function should have been
printf
2. You are running print() in a recursive loop but temp always initialized to head so in ever recursion you start from the beginning and not from the last already printed...
Try this:
int main()
{
int i,n,x;
head=NULL; printf("how many number?");
scanf("%d",&n);
for(i=0;i<n;i++){>
printf("ENTER THE NUMBER:\n");
scanf("%d",&x);
insert(x);
print(head);
} getch();
}
void print(node* root)
{
struct node* temp = root; // !!! change here !!!
printf("LIST IS:");
if (temp->next!=NULL)
{
printf("%d",temp->data);
if(temp->next->next==NULL)
printf("%d",temp->next->data);
print(temp->next);
}
printf("\n"); }