您的位置:首页 > 其它

招聘题小结8.30

2013-08-30 16:14 232 查看
#include<iostream>
using namespace std;

int main()
{
char str1[] = "abc";
char str2[] = "abc";

const char str3[] = "abc";
const char str4[] = "abc";

const char *str5 = "abc";
const char *str6 = "abc";

char *str7 = "abc";
char *str8 = "abc";

if( str1 == str2)               //测试1
{
cout<<"str1==str2 equality"<<endl;
}
if( str3 == str4)
{
cout<<"str3==str4 equality"<<endl;
}
if( str5 == str6 )
{
cout<<"str5==str6 equality"<<endl;
}
if( str7 == str8 )
{
cout<<"str7==str8 equality"<<endl;
}

//   str7[0] = 'A';                //测试2 错误
//	cout<<str2<<endl;

int a[5] = {1, 2, 3, 4, 5};    //测试3
int *ptr = (int *)(&a+1);
cout<<*(a+1)<<endl;
cout<<*(ptr-1)<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: