if (typeid(variable) == typeid(std::string)) {
std::cout << variable << " is a string" << std::endl;
}
else {
std::cout << variable << " is not a string" << std::endl;
}//you can do this for every type
auto a = 10;
cout << typeid(a) << endl;
#include<iostream>
using namespace std;
main()
{
auto variable = 45;
cout << typeid(variable).name() << endl;
}
int a = 5;
cout << typeid(a).name() << endl;
Type Description
bool Stores either value true or false.
char Typically a single octet (one byte). This is an integer type.
int The most natural size of integer for the machine.
float A single-precision floating point value.
double A double-precision floating point value.
void Represents the absence of type.
wchar_t A wide character type.
// Example
std::cout << "Data-type = " << typeid(YourVariable).name() << "
";
// Syntax
typeid(YourVariable).name()
typedef unsigned int u_int; //giving 'unsigned int' a name of u_int
typedef [type] [name_of variable]