Question: Write a C function that is given a pointer to memory, the number of bytes of memory the pointer points at, and two pointers to

Write a C function that is given a pointer to memory, the number of bytes of memory the pointer points at, and two pointers to uint32_t. Your job is to treat the pointer as if it were a pointer to an array of uint32_t, find the min and max values of the array, and write the results to the locations pointed at by the uint32_t pointers.

The number of bytes will be a positive multiple of 4. Do not worry about endianess in this problem.

Note the tester has command line options -Wall -Wextra -Werror -fsanitize=address to help you catch errors.

Write a C function that is given a pointer to memory, the

Exit Full Screen code.c + New 1 #include 2 3 // Treat ptr as base address of a uint32_t array and place the min and 4 // max array values in memory where min and max point. 5 // num_bytes is a multiple of 4. 6 void min_max(void *ptr, int num_bytes, uint32_t *min, uint32_t *max) { 7 uint32_t *ptr32 = (uint32_t *)ptr; 8 // your code goes here 9 } 10 |

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!