Error: statement cannot resolve address of overloaded function

I can't seem to figure out whats causing this error: statement cannot resolve address of overloaded function . Error is before line 14 in bubblesortrand function. Thnx in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void bubblesort(int num[], int a_size)
{
   int i, j, temp;
   for(i = (a_size - 1); i >= 0; i--)
   {
       for(j = 1; j<= i; j++)
       {
           if(num[j-1] > num[j])
           {
               temp = num[j-1] = num[j];
               num[j-1] = num[j];
               num[j] = temp;
           }
       }

   }
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
void bubbleSortrand()
                   {
                       int x, input[100];
                       fstream datafile;
                       datafile.open("RandomData.txt");
                       while (! datafile.eof())
                       {
                        datafile >> input[x];
                        bubblesort(input,10);
                        cout << input[x];

                       }
                       datafile.close;
                   }
Last edited on
You forgot to append the function call operator to datafile.close.
It should look like this: datafile.close()
Thnx alot
Now that i fixed the syntax error the program runs, but there is a runtime error because it crashes when i call the function. Im trying to make the function display sorted list using the bubble sort, am i going about this the right way with the bubblesortrand funtion?
Last edited on
http://www.cplusplus.com/forum/general/112111/
`x' is uninitialized
`input' is uninitialized, ¿what's the point of sorting it?

Your reading condition is incorrect and will process an extra line.


> Im trying to make the function display sorted list using the bubble sort
read a list.
sort a list.
print a list.

Don't try to sort until you finished the reading.
thnx
Topic archived. No new replies allowed.