Link list problem->can't print the output...
Code:
/*The code*/
#include<stdio.h>
#include<stdlib.h>
typedef struct node {
int ele;
struct node *next;
}node;
void insertnode(int x);
void deletenode(int x);
void printlist();
node *head=NULL;
main(){
int i=0;
int num;
while (i<5){
//printf("Enter a element:");
//scanf("%d",&num);
insertnode(i);
i=i+1;
}
printlist();
return 0;
}
void insertnode(int x){
node *newnode;
newnode=(node*)malloc(sizeof(node));
newnode->next=head;
head=newnode;
}
void printlist(){
node *current=head;
printf("Insert order:");
while(current!=NULL){
printf("%d",current->ele);
current=current->next;
}
}
Code tagged by Hammer