您的位置:首页 > 其它

指针、数组等直观例样

2016-09-20 20:43 113 查看
#include<iostream>

#include<vector>

#include<string>

using namespace std;

int main()

{
string s1;

int n;

while (cin >>n)

{

char *s[] = { "azf", "dwg", "hjk" };
char**sp = s;
cout << **sp << " " << sp[1] << endl;
cout << *sp << " " << *(sp+1) << endl;
cout << sp << " " << *sp + 1 << endl;
cout << *s << " " << *(*(sp + 1)) << endl;
cout << s[2] << " " << **sp+1 << endl;
cout << *s[2] << " " << (*sp)[1] << endl;
cout << *s[2] << " " << *((*sp)+1) << endl;
int a[3] = { 1,3,5 };
int* q = a;
cout << *q << endl;
cout << a + 1 << endl;
cout << *a << endl;
cout << *a+1 << endl;
cout << *(a+1) << endl;
cout << *q + 1 << endl;
cout << *(q + 1) << endl;
cout << *(a + 2) << endl;
cout << *(q + 2) << endl;

}

}



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: