c++ - Validate string within short range -


i have short integer in string. eg: "123456". there api check whether string contains valid number in range of unsigned short?

thanks!

simply use stream operators input number:

istringstream istr("12346"); short s; if ((istr >> s) , istr.eof())     cout << "valid: " << s << endl; else     cout << "invalid" << endl; 

(needs header sstream.)


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -