2011.12.4 指针 字符串

#include <iostream>
#include <string>
using namespace std;
int main()
{
//  string a("fuck");
//  string b(a,2);
//  char str[] = "wonderful";
//  string c(str+3,str+6);
 char a[10] = "greatful";
 char *p = a;
 cout<<p<<endl;
 cout<<*p<<endl;
 p++;
 cout<<*p<<endl;
 p -=1;
 cout<<*p<<endl;
 p +=3;
 cout<<*p<<endl;
 p +=4;
 cout<<p<<endl;
 *(p+1)='m';
 cout<<*p<<endl;
 p -= 7;
 cout<<p<<endl;
 cout<<a<<endl;
 p += 8;
 *p = 'A';
 p -= 8;
 cout<<p<<endl;
 cout<<a<<endl;
/* cout<<a<<endl<<b<<endl<<c<<endl;*/
}

posted @ 2011-12-04 14:42  rookieeeeee  阅读(101)  评论(0编辑  收藏  举报