strange output (c)
Hi,
i have troubles understandig the following code: Code:
#include <stdio.h> main()..y? p.s. is not a homework :) .. |
Hi,
both a and b are local. Happy Penguins. |
Take this with a grain of salt as I've been off the mark today.
This should not even compile as getNumbgetNumb doesn't return a value. a and b in main scope are not initialised and are different variables to those in getNumbgetNumb scope.(edit: which kaz2100 already mentioned) |
Yes i know there are local but why output is 2 and 22? or there is no logical explanation
|
You never initialise the a and b declared in main. Thus, their value is never written to, and whatever value is left in that position in ram from whatever program ran before is printed out.
|
Quote:
The exact reasons for the value you get will be very deep in how the compiler/links/os is working. It may well be interesting, but it's not, much to do with C the language itself. |
thx for ur explanations :)
|
All times are GMT -5. The time now is 07:23 PM. |