如何检查C ++中的字符串启动 [英] how to check string start in C++
本文介绍了如何检查C ++中的字符串启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
C ++中有什么方法来检查字符串是否以特定的字符串开头(小于原始字符串)?就像我们可以在Java做的
Is there any way in C++ to check whether a string starts with a certain string (smaller than the original) ? Just like we can do in Java
bigString.startswith(smallString);
推荐答案
std::string s("Hello world");
if (s.find("Hello") == 0)
{
std::cout << "String starts with Hello\n";
}
这篇关于如何检查C ++中的字符串启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文