|

楼主 |
发表于 2020-2-28 10:53:30
|
显示全部楼层
- #include<iostream>
- #include<string>
- using namespace std;
- int main() {
- string a;
- string b;
- string c;
- string d;
- string h;
- int e;
- int f;
- int g;
- a = "折扣价发送,asdfassd,432,123";
- e = a.find(",");
- f = a.find( ",",e+1);
- g = a.find(",", f + 1);
- cout << "第一个逗号的位置:"<<e << endl;
- cout << "第二个逗号的位置:"<<f << endl;
- cout << "第三个逗号的位置:"<<g << endl;
- b = a.substr(0,e);
- c = a.substr(e+1, f-e-1);
- d = a.substr(f+1, g-f-1);
- h = a.substr(g+1);
- cout << b << endl;
- cout << c << endl;
- cout << d << endl;
- cout << h << endl;
- }
复制代码
自己给自己想了一个办法去读取这个数据了 |
|