Need help

I need to write a function that gets its array set from a text and my compiler keeps telling me there is "no matching function for call"




#include <iostream>
#include <fstream>
using namespace std;
int readdata(int , int nums1[], int []);

int main() {
int n, score1[n] , score2[n] , i;
ifstream file;
file.open("scores.txt");

file >> n ;
cout << "n=" << n << endl;
readdata(n, score1[n],score2[n]);

int readdata (int x , int nums1[n], int nums2[n]);
{


for( i= 0 ; i < 10 ; i++ ){

file >> score1[i] >> score2[i];

cout << score1[i] << "\t\t" << score2[i] << endl;

}

}
}
Please Use Code Tags! It makes it easier to read of everyone.
http://www.cplusplus.com/articles/jEywvCM9/
I don't get that error, but I do get an error on line 15 where you are incorrectly transferring your integer arrays.
Just to make it easier on you I would recommend that you just make all the variables global.
For better reading and to have a line reference:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <fstream>
using namespace std;
int readdata(int , int nums1[], int []);

int main()
{
    int n, score1[n] , score2[n] , i;
    ifstream file;
    file.open("scores.txt");

    file >> n ;
    cout << "n=" << n << endl;
    readdata(n, score1[n],score2[n]);

    int readdata (int x , int nums1[n], int nums2[n]);
    {
        for( i= 0 ; i < 10 ; i++ )
        {
            file >> score1[i] >> score2[i];
            cout << score1[i] << "\t\t" << score2[i] << endl;
        }
    }
}



Line 14: Second argument is of type int where an array of ints is expected.
Line 16ff: You're defining a function inside another functions body. This isn't allowed in C/C++.
Line 8: You're defining two arrays with an undefined size due to an undefined value of variable n.
Topic archived. No new replies allowed.