Question: Please explain the codes in each line. pointer lab in C 22 * Change the value pointed to by ptr byte-by-byte so that when returned


Please explain the codes in each line. pointer lab in C
22 * Change the value pointed to by ptr byte-by-byte so that when returned as an integer * the value is 449449. 23 24 25 26 * Hint: Remember that an int is 4 bytes. * 127 * Hint: Remember how little endian works for data storage, how is it different between an multiple bytes (int) and a single byte? 28 29 * Hint: It will be easiest to start convert 449449 into binary form and starting seeing how the endian works from there. 30 * 31 32 33 * ALLOWED : * Pointer operators: *, & Binary integer operators: -, +, * Shorthand operators based on the above: ex. +=, *=, ++, --, etc Unary integer operators: ! * * * * 34 35 36 37 38 39 * * 40 * DISALLOWED: Pointer operators: [] (Array Indexing Operator) Binary integer operators: &, &&, I, II, , >, ==, !-, ^, 1, % * Unary integer operators: ~, - */ int endianExperiment(int *ptr) { char *bytePtr = (char *)ptr; 41 42 43 44 45 // Your code here 42 int endianExperiment(int * ptr) { 343 char *bytePtr = (char *)ptr; 344 345 // Your code here 346 347 11 449449 =0x 0006DBA9 548 349 350 51 *bytePtr = OxA9; 352 bytePtr++; 353 $54 *bytePtr = 0xDB; $55 byteptr++; $56 357 *bytePtr = 0x06; $58 bytePtr++; 359 60 *bytePtr = 0x00; 361 bytePtr++; $62 363 return *ptr; 864 $65 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
