*.exe 已停止工作 Windows 正在检查该问题的解决方案
#include <iostream.h>// #include <iostream>// using std::cout;// using std::endl;#include <stdio.h>/** ** hello ** hello ** h ** Aello ** Aello ** A **/int main(void){// cout << "hello, world\n";char *str1="hello";char *str2="hello, world\n";char *const ptr1 =str1;// 指针常量/** ** 正确 **/ printf("%s \n",str1);printf("%s \n",ptr1);printf("%c \n",*ptr1);/** ** Bus error(coredump)——HP-UX benz B.11.11 U 9000/800 2294287966 unlimited-user license ** *.exe 已停止工作 Windows 正在检查该问题的解决方案——VS2010 ** **///*ptr1 ='A';// 指针常量ptr1, 指向"hello"(文字常量(右值), 它的值不能被改变)/** ** 正确 **/char ca1[]="hello";char ca2[]="hello, world\n";char *const ptr2 =ca1;// 指针常量*ptr2 ='A'; printf("%s \n",ca1); printf("%s \n",ptr2); printf("%c \n",*ptr2);// 输出 Areturn 0;}