#include#include using namespace std; int main() { string str = "Hello World!"; if(str.startswith("Hello")) { cout<<"String starts with 'Hello'"<
Output:String starts with 'Hello'
Example 2:#include#include using namespace std; int main() { string str = "The quick brown fox"; if(str.startswith("The")) { cout<<"String starts with 'The'"<
Output:String starts with 'The'In both examples, we are checking if the given string starts with a particular substring or not. The startswith() function returns a Boolean value true if the string starts with the given substring, else it returns false. The C++ StringRef library is a part of the LLVM (Low-Level Virtual Machine) project. It is used to efficiently represent and manipulate string data in C++.