這個程序主要是保存我對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