Need help reading in specific type of file
Does anyone know of a better way (ie one that works) to read in a file called "test.b" containing brookshear machine instructions. This is what I have come up with, this compiles but performs an execution error. (file opening works fine, I must be using fscanf wrong).
FILE *code_file;
code_file = fopen("test.b", "r");
if (code_file==NULL) {
printf("Unable to open file");
exit(0);
}
for (i=0; memory[i]!=0xc0;i+=2) {
fscanf(code_file, "%x%x", &memory[i], &memory[i+1]);
}
I tried only scanning in one hex number in fscanf and increasing i by 1 but got the same error.
Any help would be great, cheers...