Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read() problem

Status
Not open for further replies.

yay4rei

Programmer
Joined
Jul 21, 2005
Messages
1
Location
US
I am writing an emulator for the Apple II, but when I try to read() a file into an array:
int load_roms(unsigned char userom[])
{
FILE *romfile; /* Create pointer to ROM file */
romfile=fopen(userom,"r"); /* Load apple.rom read-only */
if (!romfile) /* Check for problems opening the file */
{
printf("Cannot read %s \n", userom);
return 1;
}
int errcheck = read(romfile, &memory[0xF000], 1024);
if(errcheck = -1)
{
printf("ROM-File read error \n");
}
else printf("Bytes Read: %i \n", errcheck);

fclose(romfile); /*Close romfile */
return 0;
}

it returns -1! What am I doing wrong?
 
if (errchk == -1)...

The comparison operator is == not =.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top