For a HW assignment I have to use an incomplete program with pointers to create a memory map table. How do I use a loop to create a table for this program?
Prompt:
Show the memory map at the point the program reaches the system("pause"); statement.
I'm on macOS by the way, so the system pause statement is irrelevant and does not work for me.
You have the name and the contents. To get the address of a variable use &. So to get the address of age use &age. Similar for the other variables. Note if you need to display the address of a char, you need to cast to void* - otherwise it is treated as a c-style string.
I did not include the address because I just want to find the contents
age = 30
value = 7
pressure = 45.7
Mass = 2.3489
name = 45.7
Variable CONTENTS ADDRESS
age 30
value 7
pressure 45.7
Mass 2.3489
name 45.7
p_data 0x7ffee3560584
p_value 0x7ffee3560588
p_one 0x7ffee3560580
p_two 0x7ffee356057c
p_name 0x7ffee3560560
I think I am doing this right but would there be a better way to print the memory map?