+ 1
How to check whether a given number is integer or float type in C++?
3 Antworten
+ 3
Include typeinfo library and use typeid().name()
#include <typeinfo>
...
cout << typeid([variable]).name() << endl;
+ 2
#include <typeinfo>
...
cout << typeid(variable).name() << endl;
+ 2
You could use modf from math library to extract decimal part and check if it is zero. Example:
https://code.sololearn.com/c29OHjXbSokC/?ref=app