what if the substring whose index needs to be searched doesn’t exist in the string… so find function return error or -1… in that case…
Find function in cpp
It will not give an error. It will return string::npos.
What is npos? You can refer this
https://www.educative.io/edpresso/what-is-stringnpos-in-cpp#:~:text=npos%20is%20a%20constant%20static,with%20a%20value%20of%20-1.
Also go through this article