Hi friend,
Here is an about:A pointer converted into A pointer to a pointer question.
Please See my code below(Font in bold):
#include "stdafx.h"
#include
#include
using namespace std;
int _tmain(int argc, _TCHAR* argv[]){
int x;
int *p;int **q;x = 100;cout << "Address field of &x(own)=" << &x << endl;cout << "Value field of x=" << x << endl;p = &x;cout << "\nAddress field of &p(own)=" << &p << endl;cout << "Value field of p=" << p << endl;cout << "Value field of *p=" << *p << endl;q=&p;cout << "\nAddress field of &q(own)=" << &q << endl;cout << "Value field of q=" << q << endl; // Value field holds the address of the p.cout << "Value field of *q=" << *q << endl;cout << "Value field of **q=" << **q << endl;int *p2 = *q;cout << "\nAddress field of &p2(own)=" << &p2 << endl;cout << "Value field of p2=" << p2 << endl;cout << "Value field of *p2=" << *p2 << endl;q = (int**)p;cout << "\nAddress field of &q(own)=" << &q << endl;cout << "Value field of q=" << q << endl;cout << "Value field of *q=" << *q << endl; // Print result is Hex(decimal:100 -> hex:00000064). Why is not output the decimal 100?cout << "Value field of (int)*q=" << (int)*q << endl; // Converted to decimal.system("pause");return 0;
}
Thank.

VulpesPosted Jan 24, 2015, 11:09 AM
Ken HPosted Jan 25, 2015, 5:21 AM