For a school prject we have to work with pointers, for this i wanted to see the adresses of the memory but …
When i use the next piece of code :
int _tmain(int argc, _TCHAR* argv[]){
char a;
char b;
char * pa;
char * pb;
pa = &a;
pb = &b;
cout << "adress pa "<< pa <<endl;
cout << "adress pb "<< pb <<endl;
cout << "a is " << a << endl;
cout << "b is " << b << endl;
i get this as output :

Is this a characterset problem and most importantly can i correct this ?
I have tested another piece of code :
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{int x = 25;
int * p;
p = &x;
cout << "adres" << p << endl;
*p = 10;
cout << "x"<< x << endl;
cin.get();
return 0;
}
and the output is readable :

What is different ?
It is because you are dereferencing uninitialized pointers. This is undefined behavior.
One of the overloads of
<<operator in the C++ standard library interpretschar*as a C string, not as a pointer. Sine your C string is not initialized, the<<operator prints junk. There is no similar overload forint*that would interpret it as anything other than a pointer, hence you see the correct behavior in the second case.If you do not want your
char*pointer to be interpreted as a C string, cast your pointer tovoid*.(
hexlets you show the pointer using a more conventional base-16 notation).