+ 1
Can anyone explain me this !!!
10 Antworten
+ 7
https://www.sololearn.com/post/60489/?ref=app
+ 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.
0
But did see the change of value of a
0
I honestly can't explain 1st printf, but second will almost always be different because different locations in memory are available
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
0
You don't get it the value of a i mean the the value not the address
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
0
Zen
But i tried on another compiler too the values are changing similerly
- 1
Second printf prints memory location of a in integer form
- 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