What is int **ptr? and how can we use it?
What is int **ptr? and how can we use it?
none...
Thanks for reply, but for example here:
Why did you use char **str1, why didn't we just use char *str1?Code:void printStr(char **str1) { printf("String2 is %s\n", *str1); return; }
none...
>>Why did you use char **str1, why didn't we just use char *str1?
No reason to do so, *str1 would have done the job.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
int **ptr points to a pointer variable, i.e; it contains the address of a pointer variable of type integer.
#include <iostream.h>
int add( int **, int **);
int main (void)
{
int x = 4;
int y = 9;
int *ptrx = &x;
int *ptry = &y;
int result = 0;
result = add(&ptrx, &ptry);
cout << result << endl;
return 0;
}
int add( int **ptr_ptrx, int **ptr_ptry)
{
//cout << **ptr_ptrx << endl;
//cout << **ptr_ptry << endl;
return ( **ptr_ptrx + **ptr_ptry);
}
Thanks alot, Salem, Hammer, and nasir...
Now I know how to use it, and Hammer your reply helped alot, I was confused, that we used int **ptr, and now I get it.
none...
@nasir_sidd: code tags please
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]