If you indented the code properly, the reason might become apparent:
Code:
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
#define max_size = 100;
int main()
{
//float instrs[max_size];
FILE* fin;
fin = fopen("test.txt", "r");
unsigned int oneinst;
int i;
while (!feof(fin))
{
fscanf(fin, "%x", &oneinst);
int instrs[] = {oneinst};
}
for (int i = 0; i < 5; i++)
{
int opcode = (instrs[i] >> 26) & 0x3F;
}
return 0;
}
As you can see, instrs is local to the while loop, so it does not exist in the for loop. You should have declared it before the loops by uncommenting:
Code:
float instrs[max_size];
Though it looks like instrs should be an array of int, not float. Also, this would then be wrong:
Code:
#define max_size = 100;
You could have written:
Code:
const int max_size = 100;
You should not use feof to control a loop like that (why not just use C++-style I/O?), and then you need to make other changes to get your program to work.