E2FLH-1 - #include # #include #define...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<string.h> # #define max 10 /*RISHI AGARWAL ROLL NO 02 SE CMPN A */ struct customer { int cid; char name[30]; }; } void add(FILE *s, int *c) { struct customer *p,*q[10]; int i,y=0; p=(struct customer *)malloc(sizeof(*p)); printf("\nEnter The customer ID:"); scanf("%d",&p->cid); printf("\nEnter The customer NAME:"); scanf("%s",p->name); fseek(s, SEEK_SET, 0); fread(&q, sizeof(q), 1, s); for(i=0;i<=*c;i++) { printf("\nID:%d \tNAME:%s",q[i]->cid,q[i]->name); if(p->cid==q[i]->cid) { printf("\nThe customer id already exists"); y=1; break; } } if(y==0) { for(i=0;i<=*c;i++) { if(strcmp(p->name,q[i]->name)==0) { printf("\nThe customer name already exists"); y=1; break; } } } if(y==0) { (*c)++; fseek(s, SEEK_SET, 2); fwrite(&p, sizeof(p), 1, s); fseek(s, SEEK_SET, 0); fread(&q, sizeof(q), 1, s);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
printf("\nID:%d \tNAME:%s",q[*c]->cid,q[*c]->name); } /* if(*c<(max-1)) { p=(struct customer *)malloc(sizeof(*p)); printf("\nEnter The customer ID:"); scanf("%d",&p->cid); printf("\nEnter The customer NAME:"); scanf("%s",p->name); for(i=0;i<=*c;i++) { if(p->cid==a[i]->cid) { printf("\nThe customer id already exists"); y=1; break; } } if(y==0) { for(i=0;i<=*c;i++) { if(strcmp(p->name,a[i]->name)==0) { printf("\nThe customer name already exists"); y=1; break; } } } if(y==0) { (*c)++; a[*c]=p; } } else{printf("Array is full");}*/ } FILE * del(FILE *s, int *c) { struct customer *p,*q[10]; int i,y=0,z; FILE *d; if(*c==-1) { printf("Array is empty"); return NULL; } p=(struct customer *)malloc(sizeof(*p)); printf("\nEnter The customer ID:"); scanf("%d",&p->cid);
Background image of page 2
fseek(s, SEEK_SET, 0); fread(&q, sizeof(q), 1, s); for(i=0;i<=*c;i++) { if(p->cid==q[i]->cid) { y=1; z=i; break; } } if(y==0)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2010 for the course CMPN SEM3 taught by Professor Thakur during the Fall '07 term at University of Mumbai.

Page1 / 9

E2FLH-1 - #include # #include #define...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online