Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++: Check data type #190

Open
Qingquan-Li opened this issue Jun 8, 2022 · 0 comments
Open

C++: Check data type #190

Qingquan-Li opened this issue Jun 8, 2022 · 0 comments
Labels

Comments

@Qingquan-Li
Copy link
Owner

Qingquan-Li commented Jun 8, 2022

Reference:


#include <iostream>
#include <typeinfo>

using namespace std;

int main() {
    int an_int = 1;
    cout << typeid(an_int).name() << endl;         // i
    cout << typeid(-2).name() << endl;             // i
    cout << typeid(3.14).name() << endl;           // d
    cout << typeid('a').name() << endl;            // c
    cout << typeid("Hi").name() << endl;           // A3_c
    cout << typeid("Hello World!").name() << endl; // A13_c
    cout << typeid(true).name() << endl;           // b
    return 0;
}
@Qingquan-Li Qingquan-Li added the C++ label Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant