I'm having troubles in my college homework, I'm coding in c++ some sorting methods, and this just happened:
int nufi = 0, d;
cout << "nufi value: " << nufi << endl;
d = fread(&item, sizeof(ItemType), 1, stripes[nStripe].arq);
cout << "nufi value: " << nufi << endl;
That was suposed to print: nufi value: 0 nufi value :0 But, instead, is printing: nufi value: 0 nufi value: 541151813
Basically, any integer variable that passes by the fread is being changed;
I have tried to change variables names, change opened files and every test that I think and the error persist, not always with that value, when I change variables names, the number changes too, only when I remove the fread, the error disappears.
The rest of the code is fine and tested, the file opening, structs, keys, etc.
Anyone have any idea what may be happening?