Originally Posted by
vart
replace the Node* type with int and follow the code
Appreciate the responses.
As suggested, I submit the following code for your comments.
Synopsis: Two functions perform the addition operation - first receives a pointer to a pointer while the second receives simply a pointer. They both achieve the desired addition operation. The detail is for the sake of completion.
Code:
void addI(int **j){
printf("%d\n",j); // pointer's address
printf("%d\n",*j); // i's address
printf("%d\n",**j); // i
**j = **j + 1; //store at this address the content of this address added to 1
printf("---%d\n",*j);
}
void addX(int *j){
printf("%d\n",j); //x's address
printf("%d\n",*j); //x
*j = *j + 1; //store at this address the content of this address added to 1
}
int main(){
int i = 5;
int * ptrI = &i;
printf("%d\n",ptrI); //address stored by pointer i.e. i's address
printf("%d\n",&ptrI);//pointer's own address
printf("%d\n",*ptrI);//value at address stored by pointer i.e. i
addI(&ptrI);
printf("i=%d\n",i);
int x = 5;
int * ptrX = &x;
addX(ptrX);
printf("x=%d\n",x);
return 0;
}
Would appreciate your comments (corrections) against each of my comments in the code. The same would assist my understanding.
Best regards,
wirefree101