Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) What address, in base 10, does Version 1 of the addValueAtIndex function assign value to? 2) What address, in base 10, does Version 2

image text in transcribed

1) What address, in base 10, does Version 1 of the addValueAtIndex function assign value to?

2) What address, in base 10, does Version 2 of the addValueAtIndex function assign value to?

Would you mind explaining your steps as well? Thank you!

The main function: int main() { int *ptr = malloc(10 + sizeof(int)); printf("main: &ptr: %lu ", (unsigned long)&ptr); printf("main: ptr: %lu ", (unsigned long)ptr); addValueAtIndex(&ptr, 789, 2); return 0; } Version 1 of addValue Atlndex: void addValueAtIndex(int **ptr, int value, int index) { *ptr[index] = value; } Version 2 of addValueAtindex: void addValueAtIndex(int **ptr, int value, int index) { (*ptr)[index] = value; } Output - addresses in base 10 - when the program is run (64-bit compile, run on a CSL server): main: &ptr: 140721326562184 main: ptr: 11968536

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions