Hello all,
I'm getting an error in the following code, and I can't figure out why exactly. Error is as follows:
no match for 'operator>>' in 'scoresIn >> scoresArray'
this is at line 28 on the code below.
I'm trying to bring in some data from a text file into and array and just can't seem to make it happen. I've looked at examples and they all state that you can basically use the ifstream variable as a cin. Using this approach doesn't work for me. Must I use a for loop? the example code is as follows.
#include<fstream>
#include<iostream>
using namespace std;
int main ( )
{
//char opposingTeam [25];
const int initalize = 25;
int count = 1, count1, scores;
int scoresArray [initalize];
ifstream scoresIn;
for (int i = 0; i < initalize; i++) // sets scoresArray to 0
{
scoresArray[i] = 0;
}
for (int i = 0; i < initalize; i++) // checks that they are zero via cout.
{
cout << scoresArray[i] << " ";
}
scoresIn.open("scores.txt");
if (!scoresIn.fail( ))
{
cout << "Success!\n";
scoresIn >> scoresArray;
}
//scoresIn >> scoresArray[scores];
while (!scoresIn.eof( ))
{
cout << "UF game #: " << count << " score: " << scoresArray [initalize] << endl;
count++;
scoresIn >> scoresArray [initalize];
}
scoresIn.close();
cout << scores << endl;
cout << scoresArray [1] << endl;
Almost forgot, i'm using MinGW in Eclipse indigo
If the data from the text file is needed just let me know.
thanks alot for the help.
rcowboy