Phone Bill
System Project
# include <conio.h>
# include <stdio.h>
# include <alloc.h>
# include <string.h>
struct node
{
int num;
char name[15];
struct node *next;
};
struct node *list; //global start pointer
FILE *fp; // Global file pointer
struct node *getrecord()
{
struct node *temp,e;
temp=(struct node*)malloc(sizeof(struct node));
printf("Reached till here...");
getch();
fflush(stdin);
// fscanf(fp,"%d %s
",&temp->num,temp->name);
fread(&temp,sizeof(temp),1,fp);
printf("%d %s",temp->num,temp->name);
// temp->num=e.num;
// strcpy(temp->name,e.name);
getch();
temp->next = NULL;
return temp;
}
struct node *getnode()
{
struct node *temp;
temp = (struct node*)malloc(sizeof(struct node));
printf("
Enter the person's phone number--->");
scanf("%d",&temp->num);
printf("
Enter the person's Name--->");
scanf("%s",&temp->name);
temp->next = NULL;
return temp;
}
struct node *search(int id,int *flag)
{
struct node *cur,*prev;
*flag=0;
if
(list==NULL)
return NULL;
for(prev=NULL,cur=list; (cur); prev=cur,cur=cur->next)
if(cur->num == id)
{
*flag = 1;
break;
}