Does *p have an address still now? And what does the error say? | Sololearn: Learn to code for FREE!

+1

Does *p have an address still now? And what does the error say?

https://code.sololearn.com/czWF4wEffq3b/?ref=app

4/14/2021 2:49:15 PM

Mohammad Mehedi Hasan

11 Answers

New Answer

+3

At line 10, p == 0, otherwise known as a null pointer. You cannot write to that address and reading from that address caused unexpected results leading to a core dump.

+2

Correct. P is null and you can’t use it as a pointer until you point it to somewhere useful.

+2

When main() exits, regardless of the return code, memory is freed up.

+1

These two programs do not share data. The first one works properly. Then, when it exits, memory is released. The first program exits and released memory whether you use the return command or not.

+1

You printed sizeof the pointer x and the sizeof the int that p points to. The pointers size is different than the int size.

0

That means *p has no value now?

0

And yeah does "return 0" clears my RAM after execution of main function?

0

0

https://code.sololearn.com/cgYuqke5mrPm/?ref=app https://code.sololearn.com/cw4wa3LWxdj7/?ref=app Sir, in "(" file I store 8 inside *p.. I tried to cout it in another file "((" But doesn't work though I removed return 0 And what should I call *p?? Pointer or Variable??

0

Another point, in file "(" pointer *p's size is 4 bytes but x's size is 8..how?

0