+ 1

How to check whether a given number is integer or float type in C++?

27th Jul 2018, 7:41 AM
Nikash
Nikash - avatar
4 Respuestas
+ 3
Include typeinfo library and use typeid().name() #include <typeinfo> ... cout << typeid([variable]).name() << endl;
27th Jul 2018, 7:46 AM
apex137
apex137 - avatar
+ 2
#include <typeinfo> ... cout << typeid(variable).name() << endl;
27th Jul 2018, 8:15 AM
Negar Kamranian
+ 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
18th Dec 2018, 4:07 PM
Javier Felipe Toribio
Javier Felipe Toribio - avatar