Tuesday, 10 January 2012

Write Sequential File in C


#include< stdio.h>
#include< stdlib.h>

int main()
{
    int hesap;
    char isim[30];
    double bakiye;
    
    FILE*cfPtr;
    
    if((cfPtr=fopen("musteri.txt","w"))==NULL)
    printf("Dosya acilamadi\n");
    else{
         printf("Hesap numarasini,ismi ve bakiyeyi giriniz.\n");
         printf("EOF ile veri girisini sonlandiriniz\n");
         printf("? ");
         scanf("%d%s%lf",&hesap,isim,&bakiye);
         
         while(!feof(stdin))
         {
                fprintf(cfPtr,"%d %s %.2f\n",hesap,isim,bakiye);
                printf("? ");
                scanf("%d%s%lf",&hesap,isim,&bakiye);            
                            
                            }
         fclose(cfPtr);
         }
    system("pause");
    return 0;
    
    }

No comments:

Post a Comment