Hello all,
This question raised in my head, and I got confused with an answer.
So suppose I have following situation:
Code:
int val1 = 2;
double val2 = 3.25;
int *ptr1;
double *ptr2;
In such a case when I swap between them, the "3.25" will be truncated to 3.
On the other side int 2 will become of type double (2.0).
Then I've thought about using "pointer to pointer" solution,
But stuck there also.
Cause in this case I'll still need to use some "transient" pointer (*tempPtr)
But what type it should be (int/doube/void)?
The same question is about pointer to pointer definitions.
For instance, is it normal to define **ptr of type int, and make a following stuff:
Code:
int val = 1;
double val2 = 2.0;
int *ptr;
double *ptr2;
int **ptr3;
ptr = &val;
ptr2 = &val2;
ptr3 = &ptr1;
// and then
*ptr3 = ptr2;
Thanks in advance for your help.
UPD: At last code section I've asked about two aspects:
1. when making an assignment : *ptr3 = ptr2, the **ptr3 structure appears to cnahge into: int addres which points to double address.
2. ptr1 (which originaly defined ad int *) will now point val2 (which was defined to be of type double)
So my question is about these two statements.