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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib> //need this for my compiler to recognize exit.
using namespace std;
struct playerInfo
{
char playerName[25];
int goalsScored;
int Assist;
};
int buildAr(playerInfo);
int main()
{
const int AR_SIZE = 35;
playerInfo information[AR_SIZE];
int inArray;
inArray = buildAr( information );
}
int buildAr( playerInfo players[] )
{
ifstream inFile;
playerInfo player;
int i=0;
inFile.open( "binary_hockey.txt", ios::binary);
if ( inFile.fail() )
{
cout << "The binary_hockey.txt file did not open";
exit (1);
}
inFile.read( (char *) &player, sizeof(playerInfo) );
while (inFile)
{
players[i] = player;
i += 1;
inFile.read( (char*) &player, sizeof(playerInfo) );
}
inFile.close();
return i;
}
|
I keep getting the error conversion from 'playerInfo*' to non-scalar type 'playerInfo' requested at line 28
I'm using g++ as my compiler on Ubuntu 10.10
Last edited on
try adding a * before ( information )
Last edited on
Now I'm getting "undefined reference to 'buildAr(playerInfo)'
Change the declaration of buildAr to int buildAr(playerInfo[]);
That did it. Thank you both for answering!