String find
Im writing a calculator. I want to include a sinus-function.
1 2 3 4 5 6 7 8
|
for(int i = 0; i < anzahlOperanden; i++){
if (zahlen.at(i) == "PI"){
zahlen.at(i) = "3.14159";
}
string umwandeln = zahlen.at(i);
int sinStelle = umwandeln.find("sin(");
|
So I know that a if-function has to follow. But what does the string.find(); function return when the sub-string is not in the string?
std::string::find
Return value:
The position of the first character of the first match.
If no matches were found, the function returns string::npos.
std::string::npos
http://www.cplusplus.com/reference/string/string/npos/
In short, it returns -1 when a match is not found
Topic archived. No new replies allowed.