I encountered a funny problem and don't know what to make of it. The following code allows to print the correct name in the main function which was entered in *getname()!! Thats weird because the char array and the pointer should be deleted after the function ends. What makes me wonder even more is: when the name gets written directly into the derefrenced pointer (cin >> *p_name //line27) and line 31 is left away. The name is no longer available in main.
The change in lines 27 and 31 should not have an effect on the outputting string in main, or am I missing something?