/*………Hey guy’s this is a program to Create a sequential file………… */
#include <stdio.h>
#include <stdio.h>
/*…Main Function Start’s….*/
void main()
{
void main()
{
/*…Initialization and Declaration..*/
int account;
char name[ 30 ];
double balance;
FILE *cfPtr; /* cfPtr = clients.dat file pointer */
int account;
char name[ 30 ];
double balance;
FILE *cfPtr; /* cfPtr = clients.dat file pointer */
/*…Condition Checking…*/
if ( ( cfPtr = fopen( “clients.dat”, “w” ) ) == NULL )
printf( “File could not be opened\n” );
else {
printf( “Enter the account, name, and balance.\n” );
printf( “Enter EOF to end input.\n” );
printf( “? ” );
scanf( “%d%s%lf”, &account, name, &balance );
while ( !feof( stdin ) )
if ( ( cfPtr = fopen( “clients.dat”, “w” ) ) == NULL )
printf( “File could not be opened\n” );
else {
printf( “Enter the account, name, and balance.\n” );
printf( “Enter EOF to end input.\n” );
printf( “? ” );
scanf( “%d%s%lf”, &account, name, &balance );
while ( !feof( stdin ) )
{
fprintf( cfPtr, “%d %s %.2f\n”,
account, name, balance );
printf( “? ” );
scanf( “%d%s%lf”, &account, name, &balance );
fprintf( cfPtr, “%d %s %.2f\n”,
account, name, balance );
printf( “? ” );
scanf( “%d%s%lf”, &account, name, &balance );
}
fclose( cfPtr ); /*…Close The File..*/
}
getch();
}
fclose( cfPtr ); /*…Close The File..*/
}
getch();
}
/*….Main Function End’s…*/
/*..The output is…:::::::
No comments:
Post a Comment