72 int fread_be(
int* aa,
int size,
int nb, FILE* fich) {
80 bool little_endian = ( *(
reinterpret_cast<char*
>(&itest) ) == 1) ;
84 int size_tot = 4 * nb ;
86 char* bytes_big =
new char[size_tot] ;
88 int nr = int(fread(bytes_big, 1, size_tot, fich)) ;
90 char* pbig = bytes_big ;
91 char* plit =
reinterpret_cast<char*
>( aa );
93 for (
int j=0; j< nb; j++) {
95 for (
int i=0; i<4; i++) {
104 delete [] bytes_big ;
111 return int(fread(aa, size, nb, fich)) ;
120 int fread_be(
double* aa,
int size,
int nb, FILE* fich) {
128 bool little_endian = ( *(
reinterpret_cast<char*
>(&itest) ) == 1) ;
132 int size_tot = 8 * nb ;
134 char* bytes_big =
new char[size_tot] ;
136 int nr = int(fread(bytes_big, 1, size_tot, fich)) ;
138 char* pbig = bytes_big ;
139 char* plit =
reinterpret_cast<char*
>( aa );
141 for (
int j=0; j< nb; j++) {
143 for (
int i=0; i<8; i++) {
144 plit[i] = pbig[7-i] ;
152 delete [] bytes_big ;
159 return int(fread(aa, size, nb, fich)) ;
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.