Question on the below c++ code, 3rd line from bottom of below code, the line :

cout << ps << " at " << (int *) ps << endl;

It prints out "fox at 0xb82b78"

when I change it to :
cout << ps << " at " << ps << endl;

It still prints out "fox at 0xb82b78"
expected behavior - print "fox at fox"

I thought if you want to see the Address of the string (ps) you have to type cast
the pointer to another pointer type, such as (int *) ?


// ------------------------------
// c++ program
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
char animal[20] = "bear"; // animal holds bear
const char* bird = "wren"; // bird holds address of string
char* ps; // uninitialized

cout << animal << " and "; // display bear
cout << bird << "\n"; // display wren
//cout << ps << "\n"; // may display garbage, may cause crash

cout << "Enter a kind of animal: ";
cin >> animal; // ok if input is < 20 characters
//cin >> ps; // to horrible to try; ps doesn't point
// to allocated space

ps = animal; // set ps to point to string
cout << ps << "!\n"; // ok, same is using animal
cout << "Before using strcpy():\n";
cout << animal << " at " << (int *) animal << endl;
cout << ps << " at " << (int *) ps << endl;

ps = new char[strlen(animal) + 1]; // get new storage
strcpy(ps, animal); // copy string to new storage

cout << "After using strcpy():\n";
cout << animal << " at " << (int*) animal << endl;
cout << ps << " at " << (int *) ps << endl;
delete [] ps;

return 0;
}