I wonder something about finding a specific character in a string.
What I am trying is to find "*" and if that character is found in the string, I will
write "Found" to a file.
When running the code below. All this is happening but the same thing is happening
if I change the string1 to "Number1 - Number2".
So I wonder if I could have missed anything here ?

ofstream File1;
File1.open("C:\\File1.txt");

std::string string1 = "Number1 * Number2";

if( string1.find("*") )
{
    File1 << "Found";
}

this is because:
Return Value for string.find(...) is:
1) The position of the first occurrence in the string of the searched content.
or
2) If the content is not found, the member value npos is returned.

so your if(...) always evaluates to true.

Yes this was the problem. Thank you,
I will experiment with this.

this is because:
Return Value for string.find(...) is:
1) The position of the first occurrence in the string of the searched content.
or
2) If the content is not found, the member value npos is returned.

so your if(...) always evaluates to true.

This question has already been answered. Start a new discussion instead.