I'm trying to understand at a fundamental level what is the difference in C/C++ between a pointer to an int and a pointer to a char. Consider the following:
#include <iostream>
int main() {
int n = 4;
int* pn = &n;
std::cout << pn << std::endl;
char c = 't';
char* pc = &c;
std::cout << pc << std::endl;
return 0;
}
The output is:
004FFC38
t╠╠╠╠╠╠╠╠8ⁿO
Why does the int pointer return an address as expected but the char pointer returns the actual character followed by seemingly junk values? After searching I was unable to locate a direct answer to this one.