ok i am needing to build a program that searches a clients.dat folder and pulls up a a last name, first name and then an option to search for groups of measuments
here is the main program that writes to and updates clients.dat and im also having trouble getting this to run together
if ( ( cfPtr = fopen( "credit.dat", "rb" ) ) == NULL ) {
puts( "File could not be opened." );
}
else {
printf( "%29s%29s%29s\n", "Last Name", "First Name", "Email" );
while ( !feof( cfPtr ) ) { result = fread( &client, sizeof( struct clientData ), 1, cfPtr );
if ( result != 0 && client.lastname != 0 ) {
printf( "%-16s%-16s%-16s\n", client.lastname, client.firstname, client.email );
}
}
fclose( cfPtr );
}
}
int write(void)
{
char lastname[30];
char firstname[30];
char email[30];
FILE *cfPtr;
if ((cfPtr = fopen("clients.dat", "w")) == NULL){
puts("File could not be opened");
}
else{
puts("Enter the Last name, First name, and Email.");
puts("Enter EOF to end input.");
printf("%s", "?");
scanf("%29s%29s%29s", lastname, firstname, email );
int update(void)
{
char lastname[30];
char firstname[30];
char email[30];
FILE *cfPtr;
if ((cfPtr = fopen("clients.dat", "r+")) == NULL){
puts("File could not be opened");
}
else{
puts("Enter the Last name, First name, and Email.");
puts("Enter EOF to end input.");
printf("%s", "? ");
scanf("%29s%29s%29s", lastname, firstname, email );