string类的常用功能演示

这个程序可用随着我对string的用法的增多而有调整。

/*
功能说明:
	string类的常用功能演示。
实现方式:
	主要是演示string的常用函数的用法和它与字符数组的区别与联系
限制条件或者存在的问题:
	无
*/
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char **argv)
{
	cout << "process begin at " << (void*)&main << endl;

	//string对象和字符数组的比较。说明string对象可以直接和字符数组的内容进行比较。
	string str = "hello;1";
	cout << "string is " << str << endl;

	if (str == "hello;1")
	{
		cout << "str == hello;1" << endl;
	}
	else
	{
		cout << "str != hello.1" << endl;
	}

	return 0;
}

 程序结果:

process begin at 0087152D
string is hello;1
str == hello;1

原文地址:https://www.cnblogs.com/babyha/p/6443761.html