Timeline for Memory allocation when using struct to defined a user defined type
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 23, 2015 at 18:41 | vote | accept | hagrawal7777 | ||
Jul 23, 2015 at 18:41 | comment | added | hagrawal7777 | Thanks for your inputs. I have few more questions but I am working on first clearing them myself, if not then I will need your help again. For now I have accepted your answer. | |
Jul 21, 2015 at 20:32 | history | edited | kzidane | CC BY-SA 3.0 |
added 1634 characters in body
|
Jul 19, 2015 at 14:53 | comment | added | hagrawal7777 |
"what you're actually doing is giving your i2 pointer the address 0x10. Remember that pointers store addresses, not values.". I am not sure if that's true because I can do int* i2 = 10; and then print some i2 which will give me 10.
|
|
Jul 19, 2015 at 14:52 | comment | added | hagrawal7777 |
Thanks for inputs. Follow up questions - (1.) So, you mean GetString() actually allocates memory in the heap while char* on stack, are you sure about it? Even if I accept user input on char* I need not to define the size of user input. (2.) "The actual string literal "hello" is stored in the read only memory section." You mean heap memory? (3.) int* i2 mean i2 is a pointer and will have address pointing to heap memory and int i2 means i2 is just an int on stack.
|
|
Jul 19, 2015 at 1:19 | history | answered | Irene | CC BY-SA 3.0 |