Link to home
Start Free TrialLog in
Avatar of List244
List244

asked on

Help with **

int *Function(int **,int *,int); //prototype

int *Function(int **y,int *z,int r)//function

Hi, can someone explain exactly what this is, and when it would be used?
Or possibly provide a tutorial on this subject?
ASKER CERTIFIED SOLUTION
Avatar of jhshukla
jhshukla
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of List244
List244

ASKER

What would I be doing wrong here?

#include <iostream>

using namespace std;

int MyFunc(int **Array);

int main()
{
      int ret = 0;
      int x[3][3]= {{1,2,3},{4,5,6},{7,8,9}};
      ret = MyFunc(x);
      return 0;
}

int MyFunc(int **Array)
{
      return 0;
}
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
int x[3][3] has dimension information in it i.e. it is int *x[3]. While **Array doesn't have any dimention information in it. So the are different datatypes and so can't be assigned to each other. Only one dimension can be "not specified". So you need to change it to

#include <iostream>

using namespace std;

int MyFunc(int (*Array)[3]);

int main()
{
     int ret = 0;
     int x[3][3]= {{1,2,3},{4,5,6},{7,8,9}};
     ret = MyFunc(x);
     return 0;
}

int MyFunc(int (*Array)[3])
{
     return 0;
}




OR



#include <iostream>

using namespace std;

int MyFunc(int Array[][3]);

int main()
{
     int ret = 0;
     int x[3][3]= {{1,2,3},{4,5,6},{7,8,9}};
     ret = MyFunc(x);
     return 0;
}

int MyFunc(int Array[][3])
{
     return 0;
}
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial