Sep 25, 2014 at 1:36am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include <iostream>
using namespace std;
void myfunc(int * ); // what do i put in these parameters to accept a mem loc of a pointer
int main ()
{
int x = 5;
int * ptr;
myfunc(&ptr); ///This is how i want to pass the pointer to the function!
return 0;
}
void myfunc(int *)
{
}
SOLUTION:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include <iostream>
using namespace std;
//Purpose to create a function that returns a pointer to a pointer
int ** myfunc(int **);
int main ()
{
int x = 5;
int * ptr;
int ** ptrp;
cout << &ptr << endl;
ptrp = myfunc(&ptr);
cout << endl;
cout << ptrp << endl;
cout << endl << endl;
return 0;
}
int ** myfunc(int ** intpp)
{
cout << intpp;
return *&intpp;
}
Last edited on Sep 25, 2014 at 1:50am UTC
Sep 25, 2014 at 8:18am UTC
surely the memory address is just an integer?
Sep 25, 2014 at 12:56pm UTC
Face palm on Line 32, actually that whole function OP. Did you have an actual question here before your edit?
Sep 26, 2014 at 2:33am UTC
I found out how to do it before anybody replied so i figured I add the answer instead of delete the post.