Tuesday, 10 January 2012

Basic File Reading in C

#include< stdio.h>
#include< stdlib.h>
int main()
{
int hesap;
char ad[30];
double bakiye;
FILE*fPtr;
fPtr=fopen("musteri.txt","r");
if(fPtr==NULL)
printf("Dosya Bozuk!!!");
else{
printf("%-10s%-13s%s\n","hesap","isim","bakiye");
fscanf(fPtr,"%d%s%lf",&hesap,ad,&bakiye);

while(!feof(fPtr)){
printf("%-10d%-13s%7.2f\n",hesap,ad,bakiye);
fscanf(fPtr,"%d%s%lf",&hesap,ad,&bakiye);
}
fclose(fPtr);
}
system("pause");
return 0;
}
    

No comments:

Post a Comment