指针小心得

	string s = "shen";
	char *p  = &s[0];
	cout<<s<<endl
		<<s[0]<<endl
		<<*p<<endl;
		p++;
	cout<<*(++p)<<endl;

  突然想到的,用指针操作string,新学c++,指针真的很NB,让我头都大了,老出错,上面的简单程序我自己用来理解指针的,希望对那些有用的人有帮助。

运行结果:

shen

s

s

e

 

posted @ 2015-04-06 12:39  ashen~  阅读(50)  评论(0编辑  收藏  举报