Sequential File
Posted by mark123
Last Updated: August 03, 2012
// A c program demonstrating the writing of information into a file sequentially using the sentinel while operation.

#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *cftr;
char name[10];
float cost;
if((cftr=fopen("add.txt","w"))==NULL)
{
printf("Error file could not be opened");
exit(1);
}
else
{
printf("Please enter name  of person and cost of item:");
printf("Ctrl +z to terminate");
while(!feof(stdin)
{
fscanf(cftr,"%s%f",name,&cost);
printf("Enter name of person and cost of item");
fscanf(cftr,"%s%f",name,&cost);
}
fclose(cftr);
system("pause");
return 0;
}