这个程序主要是保存我对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