#include#include int main() { BString myString = "The quick brown fox jumps over the lazy dog"; int position = myString.FindFirst("lazy"); std::cout << "The word 'lazy' starts at position " << position << " in the string." << std::endl; return 0; }
#includeThis example creates a BString containing a quote from Shakespeare's Hamlet. It then uses FindFirst to search for the word "not" in the string, and stores the result in a boolean variable. Depending on whether the word was found or not, the program outputs either "The word 'not' was found in the string." or "The word 'not' was not found in the string." Overall, BString FindFirst is a useful function for working with strings in BeOS/Haiku applications.#include int main() { BString myString = "To be or not to be, that is the question"; bool found = (myString.FindFirst("not") != B_ERROR); if(found) { std::cout << "The word 'not' was found in the string." << std::endl; } else { std::cout << "The word 'not' was not found in the string." << std::endl; } return 0; }