Question about Pointers

Hi guys, hope everyone is doing well. I'm trying to practice with pointers a bit and tried to define what I thought was the same pointer in three different ways and got three different addresses. Anyone can explain to me what I'm doing wrong? Here is my code and the output i get

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  int main(){
	
	DateofBirth DN = { 23,06,1993 };
	printDateofBirth(DN);

	char First_Name[] = "John";
	char Last_Name[] = "Doe";

	char *FNPointer;
	FNPointer = &First_Name[0];

	char *pointerval = First_Name;

	cout << pointerval << endl;

	typedef char *pointertest;
	pointertest zz;
	zz = First_Name;
	cout << &zz <<"\n"<< &pointerval<<"\n"<<&FNPointer<<"\n"<<&First_Name<< endl;

	return 0;
}


Output:
0106FBF0
0106FBFC
0106FC08
0106FC20

I understand that maybe I'm printing the address of the pointer variable but how do I print the actual pointer. And if I were to print the actual pointer am I right to believe that all definitions are equivalent?
Thanks a bunch,
Nick
Last edited on
the pointer is the value.

char * cp = firstname;

cout << (int)cp; //this is the address of firstname[0]
cout << &cp; //this is not. This is the address of cp, which is not firstname, its the pointer's address


Last edited on
Thanks very much.
Topic archived. No new replies allowed.