First, this return an integer, not a pointer to an integer
return x+y+z;
Second, the value is on stack, so even if the pointer id as expected, the value will be trashed the call to
printf
.
You a lot of lecture ahaed to learn seriously C and C++.
Here is links to references books on C and C++ by the authors of the languages. Note than C is the ancestor of C++, so knowing C is always useful with C++.
The C Programming Language - Wikipedia, the free encyclopedia[
^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[
^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[
^]
C++ Programing Language[
^]
Learning to use the debugger will help too.
When you don't understand what your code is doing or why it does what it does, the answer is
debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.
Debugger - Wikipedia, the free encyclopedia[
^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.