【发布时间】:2013-06-04 08:03:05
【问题描述】:
在 Visual Studio 2012 中,我在搞乱指针,我意识到这个程序一直在崩溃:
#include <iostream>
using std::cout;
using std::endl;
int main ()
{
const char* pointer = nullptr;
cout << "This is the value of pointer " << pointer << "." << endl;
return 0;
}
我的意图是将pointer 设置为nullptr,然后打印地址。即使程序可以编译,它也会在运行时崩溃。有人可以解释发生了什么吗?
另外,pointer 和 *pointer 有什么区别?
【问题讨论】:
-
@jogojapan 还有很多问题的副本。