npos: Value returned by various member functions when they fail.
Note: npos = 18446744073709551615ULL (This is the value for npos in the strings of C++)
Syntax:
string::npos
For Example:
str = "abc"
str.find("d") => It returns npos value because d is not present in the string.
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){string str = "abc";if (str.find("d") == string::npos)cout << "Not present";elsecout << "Present\n";return 0;}
No comments:
Post a Comment