Answer the question
In order to leave comments, you need to log in
What is the analogue of the php function is_string() in C++?
Actually, all the functions of checking the entered data into a variable are of interest - which library is responsible for this?
And, is there any function reference like on php.net?
Answer the question
In order to leave comments, you need to log in
The directory is - MSDN.
And you don't need to check whether a variable is a string in c++ - because each variable has its own data type and it is immediately clear whether the line in front of us (an object of the String class) or not. And given that a string is an array of characters, then any (roughly speaking) memory area can be represented as an array of char
Actually, all the functions of checking the entered data into a variable are of interest.
1) Function reference - www.cplusplus.com/reference
2) Crutches like is_string() only make sense in dynamically typed languages.
C++ is a statically typed language.
It uses the std::string class to store strings.
C++ is a statically typed language, and if x is declared as string, then it is always string. And if as an int, then it is never a string. So the is_string function in C++ just doesn't make sense.
True, there are islands of dynamic typing like VARIANT from OLE - you already look at this in place ( msdn.microsoft.com/en-us/library/cc237865.aspx) and, most likely, this is not your question.
Yes, you wanted to validate input. For example, to check if a string is a number, you can use www.cplusplus.com/reference/cstdlib/strtod (don't forget to check endptr afterwards!)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question