#include<stdio.h>
#include<stdlib.h>
struct data{
int num;
struct data *forward;
};
struct data *ptr, *newelement, *record, *head;
main()
{
int i;
head=(struct data *)calloc(1,sizeof(struct data));
head=NULL;
record=head;
for(i=0;i<5;i++){
newelement=(struct data *)calloc(1,sizeof(struct data));
newelement->forward=record;
record=newelement;
newelement->num=i;
}
ptr=record;
while(ptr!=NULL){
printf("%d\n",ptr->num);
ptr=ptr->forward;
}
return 0;
}
#include<stdlib.h>
struct data{
int num;
struct data *forward;
};
struct data *ptr, *newelement, *record, *head;
main()
{
int i;
head=(struct data *)calloc(1,sizeof(struct data));
head=NULL;
record=head;
for(i=0;i<5;i++){
newelement=(struct data *)calloc(1,sizeof(struct data));
newelement->forward=record;
record=newelement;
newelement->num=i;
}
ptr=record;
while(ptr!=NULL){
printf("%d\n",ptr->num);
ptr=ptr->forward;
}
return 0;
}