18th Jan 2019, 6:29 PM
Sahil Bhakat
Sahil Bhakat - avatar
10 ответов
+ 7
https://www.sololearn.com/post/60489/?ref=app
18th Jan 2019, 11:11 PM
AKS
AKS - avatar
+ 1
Basically, b[3] = 10 modifies the memory outside of the range of b (and you really aren't supposed to ever do that), and depending on the number of variables and whatnot, the variables are not organized in the same way on the stack, resulting in b[3] = 10 sometimes overriding the value of a, c, or something else on the stack. Behavior is probably compiler-dependant, too.
18th Jan 2019, 7:41 PM
Zen
Zen - avatar
0
But did see the change of value of a
18th Jan 2019, 7:07 PM
Sahil Bhakat
Sahil Bhakat - avatar
0
I honestly can't explain 1st printf, but second will almost always be different because different locations in memory are available
18th Jan 2019, 7:08 PM
Elva
Elva - avatar
0
The first one i somehow understood but how is the value of a is changing if i try to print the address of a
18th Jan 2019, 7:10 PM
Sahil Bhakat
Sahil Bhakat - avatar
0
You don't get it the value of a i mean the the value not the address
18th Jan 2019, 7:15 PM
Sahil Bhakat
Sahil Bhakat - avatar
0
Justin I looked up the addresses I saw that if i try to printf the address of a ,the b[2] is now somehow holds the address of a
18th Jan 2019, 7:41 PM
Sahil Bhakat
Sahil Bhakat - avatar
0
Zen But i tried on another compiler too the values are changing similerly
18th Jan 2019, 7:44 PM
Sahil Bhakat
Sahil Bhakat - avatar
- 1
Second printf prints memory location of a in integer form
18th Jan 2019, 7:06 PM
Elva
Elva - avatar
- 2
&a will always be different when you print it, it's not a that is changing, it's address of a or &a & means address of
18th Jan 2019, 7:11 PM
Elva
Elva - avatar