Using an Array of Structures from File Location

The description is a bit hazy, but I have to read one line of input from the data file(watching for spaces), then store it into string "oneLine". Then build one string value to represent the first team, using an array.
oneLine - variable position
oneString - variable location
building new string into oneString

Pretty much go array position by array position checking if it's a space, if it's not, storing it into oneString.

I have to use the same function(building the string and storing it) for each "Name", "Wins" etc.

Any help would be much appreciated.


Here's the .txt file

Name Wins Losses Ties Points Points/Game
Badgers 0 0 0 0 0.0
Beavers 11 2 2 24 1.6
Bulldogs 2 11 5 9 0.5
Gophers 7 3 1 15 1.4
Mavericks 8 12 6 22 0.8
Seawolves 15 15 4 34 1.0
Totals 43 43 18 104 1.0



#include <iostream>
#include <iomanip>
#include <cstring>

using namespace std;

struct Teams
{
const int LINE_SIZE = 25;
const int LEAGUE_SIZE = 6;
typedef char teamName[LINE_SIZE+1];
typedef char league;
};
struct Headings
{
Teams teamNames[LINE_SIZE]; //need pass by reference on declaration&definition
int wins, losses, ties, points, numGames;
double pointsPerGame;
};

void getFilename( const int, const char* [], Line & ) // global function declarations
void setTeamStats( const int, const char* [], int, int, int, int, double)// not sure about passing structures....

int main( const int argc, const char* argv[] ) // general solution algorithm
{
getFilename( argc, argv, filename );

return 0;
}


void getFilename( const int argc, const char* argv[], Line & filename )
{
int n = 0;
if(argc == 1)
Line filename;
cout << "Enter source file name: ";
cin >> filename; // may want to verify the string length
cin.ignore( );
inFile.open(filename);
if(!inFile)
cout << "File not found" << filename << endl;
else
{
while ( !inFile.getline( oneLine, LINE_SIZE, ā€˜\nā€™ ).eof( ) )
inFile >> oneLine
strncpy( filename, argv[n], strlen( argv[n] ) + 1 );
n++
inFile.close();
}
return;
}

setTeamStats(wins, losses, ties, points, numGames, pointsPerGame);
for(int team =0; team < LEAGUE_SIZE; ++team)
{
for(int indivStats = 0; indivStats < 5; ++indivStats)
{
wins * 2 = points;
ties += points;
pointsPerGame = points / numGames;
}
}
Topic archived. No new replies allowed.