find 与 find.first.of()的区别或功能

LIQING LIN 2008-08-25 12:28:54
两个例子
(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 这是为什么)
...全文
95 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,204

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧