<分区>
在 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;
}
我的意图是设置一个指向nullptr
的指针
,然后打印地址。即使程序可以编译,它也会在运行时崩溃。谁能解释一下这是怎么回事?
还有,pointer
和 *pointer
有什么区别?