Question: I need to write a C program that reads a file that contains binary data. The data is in Big Endian format and I have

I need to write a C program that reads a file that contains binary data. The data is in Big Endian format and I have to convert it to little endian format. Each record in the file is 26 bytes long.

File Content:

I need to write a C program that reads a file that

Here is what I have so far, I need help with converting the data from big endian to little endian, I can use functions such as ntohl etc:

#include

#include

struct Bin {

int one: 4;

int two: 4;

float three;

int four: 2;

int five: 2;

int six: 2;

int seven: 4;

};

int main(){

struct Bin myBin;

FILE *file;

file = fopen("binout.dat", "rb");

for(int i=0;i

fread(&myBin, 26, 1, file);

printf("%d %d %f %d %d %d %d ", myBin.one, myBin.two, myBin.three, myBin.four, myBin.five, myBin.six, myBin.seven);

}

fclose(file);

}

Size 4 4 Type Integer Integer Floating Point 8 Integer Integer Integer Integer Field 4 2 6 4 Size 4 4 Type Integer Integer Floating Point 8 Integer Integer Integer Integer Field 4 2 6 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!