Currently doing a project for school, and the assignment I got was to turn a C algorithm into C++ (I started learning C++ about 10 hours ago, when I got the assignment).
Doing a function I got the error: [Error] invalid conversion from 'long int' to 'long int*' [-fpermissive]
Here I create a global variable that's used in the testInstance function
static long *c; // total capacity
This is the function that has the error.
void testInstance (Exitem **f, Exitem **l, int n, int r, int type, int v){
Exitem *a;
*f = a;
*l = &a[n-1];
c = maketest(*f, *l, type, r, v);
}
This is the function maketest (called on the line that gives me the error).
long maketest (Exitem *F, Exitem *L, int type, int r, int v){
register Exitem *J;
register long sum;
long c;
short r1;
sum = 0;
r1 = r / 10;
for (J = F; J <= L; J++){
J->w = (longRand() % (r));
switch (type){
case 1:
J->p = (longRand() % (r)) + 1;
break;
case 2:
J->p = (longRand() % (2*r1+1)) + J->w - r1;
if (J->p <= 0)
J->p = 1;
break;
case 3:
J->p = J->w + 10;
break;
case 4:
J->p = J->w;
break;
}
sum += J->w;
}
c = sum / 2;
return c;
}
My question is: What the hell am I doing wrong? How can I fix that?