c++ string 简单应用一

来源:互联网 发布:mac 网络测试工具 编辑:程序博客网 时间:2024/05/17 05:04
#include <iostream>


#include <string.h>


using namespace std;


inline void test(const char *title, bool value)
{
    cout << title << " returns " << (value ? "true" : "false") << endl;
}


int main()
{
    string s = "DEF";
    cout << "s is " << s << endl;


    string m;
    cout << "plesse enter m:";
    cin >> m;


    cout << "length of m:" << m.length() << endl;


    test("s <= \"ABC\"", s <= "ABC");
    test("\"DEF\" <= s", "DEF" <= s);
    m+=s;
    cout << "m = m + s : " << m << endl;
    cout << "length of m:" << m.length() << endl;
    return 0;
}
原创粉丝点击