Here is the program:
int siz = 0;
int n = 0;
FILE* picture;
picture = fopen("test.jpg", "r");
fseek(picture, 0, SEEK_END);
siz = ftell(picture);
char Sbuf[siz];
fseek(picture, 0, SEEK_SET); //Going to the beginning of the file
while (!feof(picture)) {
n = fread(Sbuf, sizeof(char), siz, picture);
/* ... do stuff with the buffer ... */
/* memset(Sbuf, 0, sizeof(Sbuf));
}
I need to read the file size.
I know for sure that this code compiled on another compiler.
How to correctly declare siz correctly so that the code compiles?
std::vectoris purposed for that.newandstd::vectorare your friend in these types of situations.unsigned charinstead of thecharbe better?newis probably not the OP's friend in these types of situations.std::vector. I fully agree there are much better options.