Dec 7, 2013 at 11:35am UTC
What do you mean by "line 5"?
Local array a[3] does not exist outside of the scope of the functio 'po' and therefore returning the address of the array is an error.
Dec 7, 2013 at 11:40am UTC
Hello!
I am getting this:
1 2 3 4 5 6 7
po: 0xbf57cff4
main: 0xbf57cff4xx
po: 0xbf57cff4
main: 12
This 5th line is what i do not see its cause...!
It is obviously after line 18 is being executed, and BEFORE line 22 is executed...:roll???
Last edited on Dec 7, 2013 at 11:41am UTC
Dec 7, 2013 at 1:57pm UTC
You get first "po:" from calling the po() on line 18, the first " main:" on line 18, the second "po:" from second call of po() on line 20, and the second "main:" on line 22.
Dec 7, 2013 at 2:35pm UTC
sure, but is line 20 supposed to cout it? That is confusing me!
many thnks!
Dec 7, 2013 at 4:39pm UTC
Supposed? How could we know? It is your function po() that prints something on its line 11. You should know what your code is supposed to do.
Dec 7, 2013 at 5:22pm UTC
Hello!
Line 11 causes the line 1 in executing.
Then: line 18 causes line 2 and 2 empty lines after it.(lines 3 and 4).
Then: U said line 20 causes line 5, but I do not understand this part.
Then: line 21 causes free line 6.
Then: line 22 causes line 7.
So: all clear, except line 21 causing line 5).
If I wanted var h not to be cout-ed, (but only *h), how should I write the code?
Many thanks!
Last edited on Dec 7, 2013 at 5:23pm UTC
Dec 7, 2013 at 5:46pm UTC
You do call function po() twice. Function po() prints a line. Therefore, line is printed two times.
Solution: You either do not call the function multiple times or the function does not print a line.
However, like I said the first time, the rest of your code leads to undefined results and should be changed.