Is it possible to output the type name of a variable in standard C++?
Hi everyone! I just started learning C++ and ran into a problem. I need to debug code, and often I want to know what type a variable has at a specific moment. In PHP or JavaScript, I'm used to using var_dump() or typeof, which show the type. In Python, there's type(). How do I do this in C++?\n\nI tried using typeid from , but it outputs something strange like "i" for int or "PKc" for const char*. For example:\n\n```cpp\n#include \n#include \n\nint main() {\n int a = 5;\n const char* str = "hello";\n auto x = a + 3.14;\n std::cout << typeid(a).name() << std::endl; // outputs "i"\n std::cout << typeid(str).name() << std::endl; // outputs "PKc"\n std::cout << typeid(x).name() << std::endl; // outputs "d"\n ret
No answers yet.
Log in to leave an answer
Blogs
Salaries of C++ Developers in Russia: Market Overview 2024
Optimizing TypeScript Application Performance: Tips and Examples
Working with Databases in C++: PostgreSQL and MongoDB for Beginners
C# or Python for Backend: What to Choose in Practice in 2025