String Find Last Not Of Function - C++ Programming Tutorial
C++ Course / Strings / String Find Last Not Of Function

String Find Last Not Of Function

BLUF: Mastering String Find Last Not Of Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: String Find Last Not Of Function

C++ is renowned for its efficiency. Learn how String Find Last Not Of Function enables low-level control and high-performance computing in the tutorial below.

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:

Example

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.

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:

Output

String contains : C is a procedure oriented language
24

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience