您的位置:首页 > 编程语言 > C语言/C++

一个在不同的编译器下会有不同结果的C++程序(程序本身只有四行)

2007-09-29 09:53 489 查看
1. char * str1="hello";
char * str2="hello";
*str1='p';
cout<<str2<<str1<<endl;
问执行结果?

这是在论坛上看到的一个例子,很有趣。

如果将程序改为如下,就什么问题都没有了

1. char * str1="hello";
char * str2="hello_kitty";
*str1='p';
cout<<str2<<str1<<endl;
问执行结果?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐