What is the existing period of character string in c++/c
Like the following c++ program, I define a pointer of char type in the class named "test". In the function init1(), str="hello1" , what is the existing period of "hello1". Whether the string "hello1" will be invalid if the function init1() exits ? then "str" point to the invalid field in memory. When will "hello1" and "hello2" be released by OS ?
Where is "hello1" stored in memory? Code:
#include <iostream> Code:
cout<< "hello everyone" Thanks !! |
According to the ISO/IEC 9899:1999 C standard, second edition, section 6.4.5 "String literals", subsection "Semantics", second paragraph:
Quote:
|
All times are GMT -5. The time now is 05:51 AM. |