Can any one tell me the difference between .npos and .length in the c++?

if (ss.find(out) !=ss.npos )
{
cout << ss << endl;
}

what happens if I use ss.length In place of ss.npos?

hello @sahilkhan2312000131

it will not work.

ss.npos is a constant whoose value is -1.

and find function return -1 ,if it does not find the string so use ss.npos only

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.