E2FLST1 - #include<stdio.h> #...

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 15 /*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 \nNAME:%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); }
Background image of page 1

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

View Full DocumentRight Arrow Icon
/* 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");}*/ } void del(FILE *s, int *c) { struct customer *p,*q[10]; int i,y=0,z; if(*c==-1) { printf("Array is empty"); return; } p=(struct customer *)malloc(sizeof(*p)); printf("\nEnter The customer ID:"); scanf("%d",&p->cid); fseek(s, SEEK_SET, 0); fread(&q, sizeof(q), 1, s);
Background image of page 2
for(i=0;i<=*c;i++) {
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 / 8

E2FLST1 - #include&lt;stdio.h&gt; #...

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