Question: Write a C program that will: Read the first 4 bytes of a .bin file. These bytes contain a number stored in Little Endian format.

Write a C program that will:

Read the first 4 bytes of a .bin file. These bytes contain a number stored in Little Endian format. This is to be passed back to the variable which is pointed to by num. Print the result, num, in decimal format. The next 8num bytes of data are an array of num floating point numbers. These are stored as 8 byte double precision. Allocate memory to store these floating point numbers using malloc(), and pass back a pointer to the floating point numbers, pointed to by val. Print out the results. Return 0 if successful, -1 otherwise.

As the file is in binary, you MUST use fopen("file", "rb") and fread().

FUNCTION PROTOTYPE MUST BE IN FORMAT: int read(int *num, double *val[], char *file)

(Note that *val[] is equivalent to **val)

Thank you!

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!