What does "PKc", as the output of typeid(var).name(), mean?

Viewed 3108

I'm getting PKc as the output when providing typeid(check).name() - where check is a char variable - as the argument to typeid.name()

#include<bits/stdc++.h>
using namespace std;
main()
{ 
    char check='e';
   cout<<typeid(check).name()<<"\n";
   cout<<typeid(typeid(check).name()).name();
}

output

c
PKc

Getting it even on changing the type of check from char to double

#include<bits/stdc++.h>
using namespace std;
main()
{ 
    double check=69.666;
   cout<<typeid(check).name()<<"\n";
   cout<<typeid(typeid(check).name()).name();

}

output

d
PKc

P.S. The solution suggested by @AsteroidsWithWings does provide the bare-bones of the underlying concepts but doesn't specifically answers what "PKc" means.

2 Answers

That string is returned from a std::type_info::name() function call. The result of that function is implementation-specific, that is the C++ standard does not require all compilers to return some specific string. Instead, each compiler is allowed to invent its own string representation of C++ type names. Compilers are not required to make that string easily readable.

Very likely, "PKc" is the string that your particular compiler is using to represent const char* type, which is the return type of std::type_info::name() function.

Related