C++ mixed string intercepting
So far, s.ind(str) always returns -1. Intercepting after eight bits with s.ubstr(idx) results in an error
#include<iostream>
#include<string>
#include<regex>
#include<cstdlib>
#include< locale>
#include <codecvt>
using namespace std;
void cut(wstring a) {
wstring next;
wstring h = L"荣耀";
int head,end;
wregex regexstr(L"^0.*"); //输入多行字符串处理,直到输入一个以0开头的字符串结束。
wsmatch resault;
if (regex_match(a, resault, regexstr)) cout<<"back"<<endl;
else {
getline(wcin, next);
cut(next); //用递归实现处理完一并输出
}
head = a.find(h); //返回值恒为-1
if(head>0)
wcout<<a.substr(head)<<endl; //只有把head改成具体值(<=8)可以截取
}
int main()
{
wstring a;
getline(wcin,a);
cut(a);
}
Just learn c++, at the beginning string can not handle Chinese characters to wstring, want to get the specified string position before intercepting, but s.ind and s.ubstr now have problems, please save!!
0 Answer
No answer yet
这家伙很懒,什么都没留下...