This is my code:
FILE* fLeftResult = fopen("C:/Users/Vincenzo/Desktop/unina/SOC/progetto esame/elaborazione fir/ResultLowLeft.bin","r+");
short output;
short matlabIdeal[SAMPLES+1] = {0};
size_t returnValue= fread(matlabIdeal, sizeof(short), SAMPLES, fLeftResult);
When SAMPLES is 6077, the array matlabIdeal is filled until the 4095th value. The successive values are 0. And returnValue is 1433.
When SAMPLES is 60772, the array matlabIdeal is filled until the 59391th value. The successive values are 0. And returnValue is 1433.
When SAMPLES is 30772, the array matlabIdeal is filled until the 30719th value. The successive values are 0. And returnValue is 1433.
The values that fread() fills are correct, but suddenly they became 0. This is the binary file fread reads: https://ufile.io/sf85m Can you help me with this problem? Or reproduce the code on your computer to see what will happen?
This is because you did not open the file for reading binary data.
fread is treating the stream as though it is text.
You should open the file using the "rb" mode.