I'm using the Turbo C 2.01 compiler for this example that I copied out of the book "Hands - on Turbo C" by Larry Joel Goldstein and Larry Gritz. It appears the example has a mistake in it and I need help solving it.
Code:
#include
#include
#include
#include
#include
typedef struct {
char Name[20];
char Number[12];
} PhoneNum;
int Directory;
int accessmode;
PhoneNum Entry;
char SearchName[20];
int Found;
main()
{ /* PhoneSearch */
printf("Whose phone number to search for? ");
gets (SearchName);
accessmode = O_RDONLY | O_BINARY;
Directory = open("PHONE", accessmode);
Found = 0;
while(!Found && !eof(Directory))
if (!strcmp(SearchName,Entry.Name))
/* if Entry.Name = SearchName then - original line where error occurrs */
Found = 1;
else
read(Directory,&Entry,sizeof(Entry));
close(Directory);
if(Found)
printf("Successful: %s", Entry.Number);
else
printf("Unsucessful\n");
} /* PhoneSearch */