【发布时间】:2016-05-13 04:31:37
【问题描述】:
方案一:
#include <iostream>
using namespace std;
int main ()
{
int *ptr = NULL;
cout << "The value of ptr is " << ptr ;
return 0;
}
方案二:
#include <iostream>
using namespace std;
int main ()
{
char *ptr = NULL;
cout << "The value of ptr is " << ptr ;
return 0;
}
问题是,在程序 1 中,输出稳定为:
The value of ptr is 00000000
而在程序 2 中,我使用 char 指针而不是 int 指针,它给了我一个异常。
谁能帮我理解一下?
【问题讨论】: