#include <iostream> using namespace std; char* GetMem(void) { char p[] = "hello"; return p; }; void main() { char c[] = "a"; char* ptr = c; ptr = GetMem(); //strcpy(ptr,"hello!"); cout << ptr << endl; cout << *ptr << endl; cout << &ptr << endl; }
#include <iostream> using namespace std; char* GetMem(void) { char p[] = "hello"; return p; }; void main() { char c[] = "a"; char* ptr = c; ptr = GetMem(); //strcpy(ptr,"hello!"); cout << ptr << endl; cout << *ptr << endl; cout << &ptr << endl; }
相关文章: