how to find datatype in c++ code example
Example 1: how to check datatype of a variable in c++
#include <typeinfo>
...
cout << typeid(variable).name() << endl;
Example 2: how to check the datatype of a variable in c++
#include <typeinfo>
#include <iostream>
class someClass { };
int main(int argc, char* argv[]) {
int a;
someClass b;
std::cout<<"a is of type: "<<typeid(a).name()<<std::endl;
std::cout<<"b is of type: "<<typeid(b).name()<<std::endl;
return 0;
}
Example 3: c++ get data type
std::cout << "Data-type = " << typeid(YourVariable).name() << "\n";
typeid(YourVariable).name()
Example 4: how to know datatype of something in c++
int k;
cout << typeid(k).name() << endl;