c++ string 里有StartWith或其他类似的功能吗
答案:1 悬赏:70
解决时间 2021-01-13 05:02
- 提问者网友:寂寞梧桐
- 2021-01-12 08:40
c++ string 里有StartWith或其他类似的功能吗
最佳答案
- 二级知识专家网友:笑迎怀羞
- 2021-01-12 09:00
应该是指判断某个字符串是否以一个字符串为前缀的意思吧,可以用如下的方法:
string xx = "hello";
string dst = "he";
if (strcmp(xx.c_str(), dst.c_str()) == 0)
//是以dst字符串开头
else
//不是以dst字符串开头
string xx = "hello";
string dst = "he";
if (strcmp(xx.c_str(), dst.c_str()) == 0)
//是以dst字符串开头
else
//不是以dst字符串开头
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息