I have basically two queries. First this code is working fine I just want to print the results and second this program enters only one record. I want to save a complete address book of a record like name contact. For that I will have to give separate struct pointer for every field? Please help me out.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *link;
} *head=NULL;
void inserfirst();
int main()
{
insertfirst();
getch();
return 0;
}
void insertfirst()
{
int item;
struct node *ptr;
scanf("%d",&item);
if (head==NULL) {
head=(struct node*)malloc(sizeof(struct node));
head->data=item;
head->link=NULL;
} else {
ptr=head;
head=(struct node*)malloc(sizeof(struct node));
head->data=item;
head->link=ptr;
}
}