#include< stdio.h> struct musteriVerisi{ int hesapNo; char soyisim[15]; char isim[10]; double bakiye; }; int main(){ FILE*cfPtr; struct musteriVerisi musteri={0,"","",0.0}; if((cfPtr=fopen("kredi.dat","r+"))==NULL) printf("Dosya acilamiyor\n"); else{ printf("Hesap numarasini giriniz(1-100)\n"); scanf("%d",&musteri.hesapNo); while(musteri.hesapNo!=0) { printf("soyisim,isim,bakiye giriniz\n"); fscanf(stdin,"%s%s%lf",musteri.soyisim,musteri.isim,&musteri.bakiye); fseek(cfPtr,(musteri.hesapNo-1)*sizeof(struct musteriVerisi),SEEK_SET); fwrite(&musteri,sizeof(struct musteriVerisi),1,cfPtr); printf("Hesap numarasini giriniz(1-100)\n"); scanf("%d",&musteri.hesapNo); } fclose(cfPtr); } getch(); return 0; }
Tuesday, 10 January 2012
Random Access File Writing in C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment