Hey guys. I'm new here. I have an assignment to read from a file and emulate a computer (moving around imaginary registers, moving RAM around, etc.)
I have two file pointers. one is in my main function and one is in a different function.
here is the code up to the first error:
here is the code for my second function:
#define INPUT_FILE "interpreter.txt"
FILE *fp, *rp;
int registers, ram, freq, instruction, lines;
int s, a, d, n, l;
fp = fopen(INPUT_FILE, "r");
if (fp == NULL)
printf("Can't open %s\n", INPUT_FILE);
fscanf(fp, "%d", &lines);
for some reason, when I debug it, it doesn't seem to like the while loops. it won't even load the file once it sees that. when i print the pointers, fp and rp, it has a huge number (435557) something like that. can anyone see what I'm doing wrong? any help would be appreciated.
rp = fopen(INPUT_FILE, "r");
fscanf(rp, "%d", &f);
f = ram[i];