地址选取的莫名错误!
大神帮忙看一下这里哪错了?生成解决方案没问题,但是运行就出现“20170901.exe 中的 0x5340d540 (msvcr100d.dll) 处有未经处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突” 这种情况!#include <iostream>
#include <cstring>
int main()
{
using namespace std;
char animal[20]="bear";
const char* bird="wren";
char*ps=NULL;
cout<<animal<<" "<<bird<<" "<<ps<<endl;
cin>>animal;
ps=animal;
cout<<ps<<endl;
cout<<animal<<" "<<(int*)animal<<endl;
cout<<ps<<" "<<(int*)ps<<endl;
ps=new char[strlen(animal)+1];
strcpy(ps,animal);
cout<<animal<<(int*)animal<<endl;
cout<<ps<<" "<<(int*)ps<<endl;
delete []ps;
system("pause");
return 0;
}