0

Why is random value printed?

https://code.sololearn.com/cRwp3Whsnh9K/?ref=app in line 11 random value for extra placeholder. Shouldn't it be 0.

3rd Sep 2018, 11:11 AM
Zakaria Arzoo
Zakaria Arzoo - avatar
5 Respuestas
+ 2
well this behavior is unpredictable, you may get random value for %f on some other machine, some compilers may give you warning, you never know
3rd Sep 2018, 11:23 AM
‎ ‏‏‎Anonymous Guy
+ 2
When a function is called, the arguments are placed on the stack. Put 2, and took 3. The third item on the stack already exists. The stack is large and is used by all functions. The additional item MUST be random. Riddle - why '%f' is not random?
3rd Sep 2018, 11:47 AM
Sev Divov
Sev Divov - avatar
+ 1
it doesn't work that way, if you use %d you must specify a corresponding variable
3rd Sep 2018, 11:16 AM
‎ ‏‏‎Anonymous Guy
0
yes. but if I don't you should get a 0. just like for %f you get 0.000000
3rd Sep 2018, 11:17 AM
Zakaria Arzoo
Zakaria Arzoo - avatar
0
Sev Divov try c compiler for android, your array will never be out of index and any call to undeclared variables will return error or (mostly) zero. So it's really upto compiler settings and design.
3rd Sep 2018, 4:54 PM
‎ ‏‏‎Anonymous Guy