c++ point operation

#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int main(int argc,char *argv[]){
	
	//string hello = "hello";
	char *p = "hello";	
	cout << p << endl;
	cout << "print string as old:" << endl;
	for(int i = 0; i < strlen(p); i++){
		cout << *(p+i);
	}
	cout << endl;

	cout << "print each point to the char in string :" << endl;
	for (int i = 0; i < strlen(p); i++){
		cout << p+i << endl;
	}	
	cout << endl;
	return 0;
}

 
posted @ 2011-06-19 20:54  Podevor  阅读(203)  评论(0编辑  收藏  举报