Скажем, у меня есть двоичный файл; он содержит положительные двоичные числа, но написанный в little endian как 32-битные целые числа
Как я могу прочитать этот файл? У меня есть это прямо сейчас.
int main() {
FILE * fp;
char buffer[4];
int num = 0;
fp=fopen("file.txt","rb");
while ( fread(&buffer, 1, 4,fp) != 0) {
// I think buffer should be 32 bit integer I read,
// how can I let num equal to 32 bit little endian integer?
}
// Say I just want to get the sum of all these binary little endian integers,
// is there an another way to make read and get sum faster since it all
// binary, shouldnt it be faster if i just add in binary? not sure..
return 0;
}