C++: how find a dot on a word\number?

i get these print:
"0.45"
ok... these number is found on vector.
now i must test if i get the dot:
1
2
3
4
5
cout << "\ntest: " << tokens[index].Description << "\n";
if( tokens[index].Description.find('.')!=std::string::npos)// && (strVarType!="double" && strVarType!="float"))
                {
                    WarningList.push_back("Line: " + to_string(LineError)  + " - Warning: the number '" + tokens[index].Description + "' parameter is double, but must be '" + strVarType + " ' !!!!\n");
                }

is these 'if' right:
if( tokens[index].Description.find('.')!=std::string::npos)
???
Last edited on
Seems correct to me.

If you're getting an error with that line then check whether tokens[index].Description returns a string.

fixed.. i commented the warning list, that's why i wasn't getting the warning's list.
1
2
3
4
5
6
7
8
9
if( tokens[index].Description.find('.')==std::string::npos && (strVarType=="double" && strVarType=="float"))
                {
                    WarningList.push_back("Line: " + to_string(LineError)  + " - Warning: the number '" + tokens[index].Description + "' parameter is integer, but must be '" + strVarType + " ' !!!!\n");
                }

                if( tokens[index].Description.find('.')!=std::string::npos && (strVarType!="double" && strVarType!="float"))
                {
                    WarningList.push_back("Line: " + to_string(LineError)  + " - Warning: the number '" + tokens[index].Description + "' parameter is double, but must be '" + strVarType + " ' !!!!\n");
                }

some mistakes aren't easy to find.. i'm sorry
thank you so much for all
Topic archived. No new replies allowed.