FILE1 - printf("\nPress 0 to add...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
L #include <stdio.h> # struct customer { int id; char name[30]; }; } void main() { FILE *stream; struct customer s[10],q[10]; int z,i=0,j; clrscr(); do{ printf("Enter Customer ID:"); scanf("%d",&s[i].id); printf("Enter Customer NAME:"); scanf("%s",s[i].name); stream = fopen("customer.txt", "w+"); fwrite(&s, sizeof(s), 1, stream);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf(&quot;\nPress 0 to add more&quot;); scanf(&quot;%d&quot;,&amp;z); i++; }while(z==0); fseek(stream, SEEK_SET, 0); // fprintf(stream, &quot;\nId:%d \nName:%s &quot;,s.id,s.name); / fread(&amp;q, sizeof(s), 1, stream); for(j=i;j&gt;0;j--) printf(&quot;\nID:%d \nNAME:%s&quot;,q[j].id,q[j].name); fclose(stream); getch(); }...
View Full 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.

Ask a homework question - tutors are online