This function is utilized to scan the string for the final character that differs from any of the specified characters within the string.
Syntax
Consider two strings labeled as str1 and str2. The syntax for this operation is as follows:
str1.find_last_not_of(str2);
Parameters
str : str is the string to be used in searching.
It specifies the starting position for the search operation.
n : Number of characters that specify which characters to search for.
ch : It specifies the character to look for within the given context.
Return value
This function provides the index of the final character that differs.
Examples 1
Let's see the simple example.
#include<iostream>
using namespace std;
int main()
{
string str = "C is a procedure oriented language";
cout<< "String contains :" << str <<'\n';
cout<< str.find_last_not_of("C is a structural language");
return 0;
}
Output:
String contains : C is a procedure oriented language
24