69int fread_be(
int* aa,
int size,
int nb, FILE* fich) {
77 bool little_endian = ( *(
reinterpret_cast<char*
>(&itest) ) == 1) ;
81 int size_tot = 4 * nb ;
83 char* bytes_big =
new char[size_tot] ;
85 int nr = int(fread(bytes_big, 1, size_tot, fich)) ;
87 char* pbig = bytes_big ;
88 char* plit =
reinterpret_cast<char*
>( aa );
90 for (
int j=0; j< nb; j++) {
92 for (
int i=0; i<4; i++) {
101 delete [] bytes_big ;
108 return int(fread(aa, size, nb, fich)) ;
117int fread_be(
double* aa,
int size,
int nb, FILE* fich) {
125 bool little_endian = ( *(
reinterpret_cast<char*
>(&itest) ) == 1) ;
129 int size_tot = 8 * nb ;
131 char* bytes_big =
new char[size_tot] ;
133 int nr = int(fread(bytes_big, 1, size_tot, fich)) ;
135 char* pbig = bytes_big ;
136 char* plit =
reinterpret_cast<char*
>( aa );
138 for (
int j=0; j< nb; j++) {
140 for (
int i=0; i<8; i++) {
141 plit[i] = pbig[7-i] ;
149 delete [] bytes_big ;
156 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.