Function return is not assigned to a variable

What if you call a function (not void) but don’t assign its return value to a variable? e.g. getchar ();

I always wondered what happens with such a value. I heard humorous explanations such as "it went on the air", etc., but I really would like to know really. Is there any way to restore this value? Thanks

+3
source share
4 answers

No you will not.

The value flies out of the stack and disappears.

If you need to return a value, you must assign it to a variable.

+4
source

/, CPU ( ), , , . " ".

, " ". . , ... , . ...

+3

"" ( , ) , , , null.

0

If you want to know more about how it all works, you can look at this: http://en.wikipedia.org/wiki/Call_stack

0
source

Source: https://habr.com/ru/post/1753589/


All Articles