#include <iostream>
#include <string>
using namespace std;
string strTemp ="display time\r\n\
{ <cr>|date-format<K>|dst<K>|time-stamp<K> }:\r\n\
\r\n\
Command:\r\n\
display time \r\n\
2021-09-17 14:20:54+08:00\r\n\
";
int main(){
cout << "g_str = " << strTemp.c_str()<< endl;
int posClock = strTemp.rfind("display time \r\n");
int posClock1 = strTemp.find("+", posClock + 14);
string strClockTime = strTemp.substr(posClock + 14, posClock1 - (posClock + 14));
cout << "strClockTime =" << strClockTime.c_str() << endl;
cout << " posClock=" << posClock <<", posClock + 14 = "<< posClock + 14 << ", posClock1 = " << posClock1 << ", posClock + 14 = " << posClock + 14 << endl;
}
工作测试-字符串处理
最新推荐文章于 2023-08-18 09:38:59 发布