find 与 find.first.of()的区别或功能
两个例子
(1)
int nameLocation = dataString.find( "Name=" ) + 5;
int endName = dataString.find( "age:" );///////////////////////
int ageLocation = dataString.find( "age:" ) + 4;
int endAge = dataString.find( "color:" );
int colorLocation = dataString.find( "color:" ) + 6;
nameString = dataString.substr(
nameLocation, endName - nameLocation);
ageString = dataString.substr(
ageLocation, endAge - ageLocation );
colorString = dataString.substr( colorLocation );
(2)
int nameLocation = dataString.find_first_of( "word=" )+5;
int endLocation = dataString.find_first_of( "&" )-1;///////////////////////////
//retrieve entered word
wordString = dataString.substr(
nameLocation, endLocation - nameLocation );
请问,有谁知道以上两处的写法为什么不同,即(find寻尾不用-1和find_first_of寻尾要-1 这是为什么)
(1)
int nameLocation = dataString.find( "Name=" ) + 5;
int endName = dataString.find( "age:" );///////////////////////
int ageLocation = dataString.find( "age:" ) + 4;
int endAge = dataString.find( "color:" );
int colorLocation = dataString.find( "color:" ) + 6;
nameString = dataString.substr(
nameLocation, endName - nameLocation);
ageString = dataString.substr(
ageLocation, endAge - ageLocation );
colorString = dataString.substr( colorLocation );
(2)
int nameLocation = dataString.find_first_of( "word=" )+5;
int endLocation = dataString.find_first_of( "&" )-1;///////////////////////////
//retrieve entered word
wordString = dataString.substr(
nameLocation, endLocation - nameLocation );
请问,有谁知道以上两处的写法为什么不同,即(find寻尾不用-1和find_first_of寻尾要-1 这是为什么)
...全文
相关推荐
C++ string深入详解(最新版)
C++ string深入详解(最新版)。。。。。。。。。。。。。
C++find()函数用法
压缩文件中包括find()函数的说明和具体使用方法的CPP 文件,find()函数可能很多人没有使用过或者了解一些,其实是一个很使用的函数
深入C++ string.find()函数的用法总结
本篇文章是对C++中string.find()函数的用法进行了详细的总结与分析,需要的朋友参考下
高中英语 知识点大全58 find、first of all、flash的用法
高中英语 知识点大全58 find、first of all、flash的用法
Exam_09_38.rar_find_first_not_of
在标准C++库中使用find_first_of以及 find_first_not_of的使用举例。 已知有如下string对象: “ab2c3d7R4E6” 编写程序寻找该字符串中所有的数字字符,然后再寻找所有的字母字符。以 两种版本编写该程序:第一个版本使用find_first_of函数,第二个版本使用 find_first_not_of函数



