When i try to input this data:
11 jack 90
22 mike 99
the result will be on the attachment.
/*Create a sequential file*/
/*"w" is a made for creating a file for writing*/
/*if the file already exists, it will discard the current contents*/
/*%s stands for string is a placeholder for type char*/
#include <stdio.h>
main()
{
int account;
char name[30];
double balance;
FILE*cfPtr;/*cfPtr=clients.txt file pointer*/ /*what is a file pointer?*/
clrscr();
if((cfPtr=fopen("clients.dat","w"))==NULL) /*what is the function of fopen*/
printf("file could not be opened\n");
else
{
printf("Enter the account,name, and balance.\n");
printf("\nEnter EOF to end input.\n");
printf("?");
scanf("%d%s%1f",&account,name,&balance);
while(!feof(stdin)){
fprintf(cfPtr,"%d %s %.2f\n",account,name,balance); /*what is the function of fprintf?*/
printf("?");
scanf("%d%s%1f",&account,name,&balance);
}
fclose(cfPtr); /*what is the function of fclose?*/
}
return 0;
}