ALEXKK2011

The Technical Side of alexKK2011
  博客园  :: 新随笔  :: 订阅 订阅  :: 管理

stack memory

Posted on 2011-02-24 18:45  alexkk2011  阅读(108)  评论(0编辑  收藏  举报
#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;
}

 

2-1

 

2-2

 

2-3

 

2-4

 

2-5