The constant npos
I was playing with some of the string functions and the VS help says that rfind returns npos if it doesn't find the string I'm searching for in the string I'm searching in. I thought npos was some sort of enumerated type or something. But I get an error and I tried to do it like they show the examples. Anyone help me please?
--------------------Configuration: STRNG - Win32 Debug--------------------
using namespace std;
cout<<"enter a word";
//do whatever if it finds the letter
C:\Program Files\Microsoft Visual Studio\MyProjects\AddIns\Strng\main.cpp(11) : error C2065: 'npos' : undeclared identifier
Error executing cl.exe.
I think it might return NULL if the value is not found. Not sure though. Try it and see what happens.
I just realized what you were talking about. npos is the Number POSition of the characters. If it doesn't find it, it will not return a position. Hence, NULL as I already said.
THANK YOU golfnguy4:D :D :D