Errors

If there is a need to post the full code, please let me know.
i have posted only the error code which i am getting.

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>

double compare;
double swap;

    {
            CompResult = compare(Array[j], Array[IndexMinVal]);
           
        swap[(Array[i], Array[IndexMinVal]);


        }


the words which are bold and underlined are the error lines .

Error 1 error C2064: term does not evaluate to a function taking 2 arguments ---- Compare

Error 2 error C2064: term does not evaluate to a function taking 2 arguments ---- Swap

6 IntelliSense: expression must have (pointer-to-) function type ---compare

7 IntelliSense: expression must have (pointer-to-) function type ---Swap



The program should output this.


Bubble
               Comparisons Swaps
Size = 10          50       24
     = 100       4950      3100
Last edited on
It is not interesting what the program should output but is is very strange that you are trying to use an object of type double as for example

double compare;


as a function

compare(Array[j], Array[IndexMinVal])
It looks like you're trying to send arguments to two different primitive variables, which will of course return an error, as only functions can take arguments. What you should do is declare those doubles as functions with some sort of return type (depending on what it is you want them to do) and takes two arguments of whatever type Array is defined as.
compare is not a function -- it's a variable of type double.
swap is not a function -- it's a variable of type double.


#include <iostream>
using namespace std;
int main ()
{unsigned long x,nr;
unsigned c;
cout<<"x="; cin>>x;
nr=0;
if(x=0)
nr=1;
while(x!=0) {c=x%10;
nr=nr+1;
x=[x/10];
cout<<"nr="<<nr;
return 0;}
}
Please help me to correct the mistake (error: expected primary-expression before '[' token)
Topic archived. No new replies allowed.