Expand|Select|Wrap|Line Numbers
- char chipMemory [chipMemorySize]; // ~35XX
- fstream ifile;
- ifile.open(argv[1],ios::in|ios::binary|ios::nocreate|ios::ate);
- int fileLength=ifile.tellg();
- ifile.seekg(ios::beg);
- ifile.read(chipMemory,fileLength);
- ifile.close();
(short) chipMemory[0] "prints as" (printf used) 0xFFFFFFE0
(short chipMemory[2] "prints as" 0xFFFFFFEE
it should contain:
(short) chipMemory[0] == 0x00E0;
(short) chipMemory[2] == 0x00EE;
What I'm most puzzled about is that a short is 2 bytes , so the maximum short would be 0xFFFF , not even close to 0xFFFFFFE0.
I'm guessing this is because the file starts with a nul (0x00) , which is supposed
to mark the end of a file.
(Note : I'm not checking for nul in any way at all)