2FLST - #include # #define max 5 struct customer...

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

View Full Document Right Arrow Icon
#include<stdio.h> # #define max 5 # struct customer { int cid; char name[30]; }; } void main() { struct customer *p,*q[10]; FILE *stream; int choice,count=-1,y=0,i; clrscr(); stream = fopen("cust1.txt", "w+"); printf("Enter the choice \n1-Add\n2-Delete\n3-Modify\n4-Display\n0-Exit\n"); scanf("%d",&choice); do{ switch(choice) { case 0:{break;} case 1:{ //add 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(stream, SEEK_SET, 0); fread(&q, sizeof(q), 1, stream); for(i=0;i<=count;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) { count++; fseek(stream, SEEK_SET, 2); fwrite(&p, sizeof(p), 1, stream); } break; } /* case 2:{
Background image of page 1

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

View Full DocumentRight Arrow Icon
//delete printf("Enter the customer id to be deleted"); scanf("%d",&p->cid); for(i=0;i<=count;i++) { if(p->cid==s[i]->cid) {
Background image of page 2
Image of page 3
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 / 3

2FLST - #include # #define max 5 struct customer...

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

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