how to check string start in C++

后端 未结 12 2017
Happy的楠姐
Happy的楠姐 2020-11-29 03:31

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.startswi         


        
12条回答
  •  眼角桃花
    2020-11-29 04:29

    std::string s("Hello world");
    
    if (s.find("Hello") == 0)
    {
        std::cout << "String starts with Hello\n";
    }
    

提交回复
热议问题