C++ IsFloat function

前端 未结 18 1291
不思量自难忘°
不思量自难忘° 2020-12-09 15:58

Does anybody know of a convenient means of determining if a string value \"qualifies\" as a floating-point number?

bool IsFloat( string MyString )
{
   ... e         


        
18条回答
  •  隐瞒了意图╮
    2020-12-09 17:00

    This is a common question on SO. Look at this question for suggestions (that question discusses string->int, but the approaches are the same).

    Note: to know if the string can be converted, you basically have to do the conversion to check for things like over/underflow.

提交回复
热议问题