Errors with snippet of code

Hello,
I have to find the errors with the following code. Apparently there are seven of them. The getCalibration functions are assumed to be free of mistakes.
Any ideas would be greatly appreciated.

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
void getCorrectionA(double *input);
void getCorrectionB(double *input);


bool getResults( *result){

   double container = new int[2];
   getCalibrationA(container[0]);
   getCalibrationB(container);

   result = container[1]/container[0];
   if(*result > 0.1){
         return true;
   }
   else{
   return false;
   }
}

int main(){
double result = 0;
if(getResults(result)){
std::cout << result << std::endl;
}
}
closed account (o3hC5Di1)
Hi there,

As this is homework (I assume?) I'll just give some hints:

- Verify function return types and argument types with the code calling the functions. (That goes for the return type of new too).
- Verify declarations of arrays, is the type of the array name the same as the type allocated?
- Make sure you understand the difference between changing the value in the memory that a pointer points to and assigning a new value (ie memory address) to a pointer.
- Make sure the functions that are declared/called are actually defined at some point in the program.
- Make sure all the necessary header files are included.

Of course, you could just run this through a compiler - it will spot some of those errors (not all) for you.

All the best,
NwN
Thanks, that definitely helps getting me started.
Topic archived. No new replies allowed.