Wednesday, January 1, 2025

string c++

 1. find:

This function is used to locate the first occurrence of a substring (in this case, "WUB") within a string.

It helps you determine where to extract parts of the string.

size_t found = remix.find(separator);


2. substr:

Once you’ve found a substring (like "WUB"), substr is used to extract the part of the string between two "WUB" occurrences.

It takes two arguments: the starting position and the length of the substring.


std::string word = remix.substr(start, found - start);



No comments:

Post a Comment