help with displaying memory addresses
here's what i'm trying to do. I want to input a number into a variable, (int,float,double).. i want to display it's address, and display the bytes in big endian form.. (intel machines are little endian)
so, i can print the address, but &variable.. the problem is, i need the address to have spaces...
so for example, i can print "ox454567, but i want it to be 0x 45 45 67. to do this i need to go through memory byte by byte.
So, how can i go through memory byte by byte,, the code below is trying to do what i described..
but it's not working.. it keeps printing byte values inside the address
Code:
void IntType(void)
{
int num0;
char conti0;
char *addr0;
cout << endl;
cout << endl;
cout << "Enter an integer:";
cin >> num0;
addr0 = (char*)(&num0);
cout << endl;
cout << endl;
cout << "Address:0x";
cout << hex << addr0;
cout << " Big endian representation:";
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
while(1)
{
cout << "press 'c' to continue:";
cin >> conti0;
cout << endl;
if(conti0 == 'c' || conti0 == 'C') break;
}
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
}