十七、C++字符串(二)
1、字符串的应用
需求:设计一个程序,用户输入属性id或者pass或者role可以把对应的内容显示出来,给定字符串如下:
string str{"id=user;pass=632105;role=郝英俊;"};
[code]//设计一个程序,用户输入属性id或者pass或者role可以把对应的内容显示出来#include #include using std::string;int main(){ string str{ "id=user;pass=632105;role=郝英俊;" }; string strIn; string outPut; while (true) { std::cout > strIn; int lfind; //find()函数查找的值是一个整数,不是字符串 lfind = str.find(strIn + "="); if (lfind == std::string::npos)std::cout |