B
beepa
As you will be able to see I am fairly new at this. Here is the part I'm
having problems figuring out:
The file I'm inputing from is formated like this:
firstName lastName
postion name (one or two words)
firstName lastName
first base (for example)
firstName lastName
position name (one or two words)
I'm trying to seperate the first name from the last name putting the last
name in parallel arrays with the position in the
other array. The garbage array I set up just to see what I was getting rid
of. When the position has two words it always gets messed up as far as what
it puts in the arrays the code is runable. Any suggestions would be most
welcome. TIA (This is just a C++ win32console program created in an empty
solution using MS Visual Studio 2005)
having problems figuring out:
The file I'm inputing from is formated like this:
firstName lastName
postion name (one or two words)
firstName lastName
first base (for example)
firstName lastName
position name (one or two words)
I'm trying to seperate the first name from the last name putting the last
name in parallel arrays with the position in the
other array. The garbage array I set up just to see what I was getting rid
of. When the position has two words it always gets messed up as far as what
it puts in the arrays the code is runable. Any suggestions would be most
welcome. TIA (This is just a C++ win32console program created in an empty
solution using MS Visual Studio 2005)
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
char sentry;
string garbage[9];
string player[9];
string position[9];
fstream inFile;
inFile.open("team1.txt");
for(int test = 0; test < 9; test++)
{
inFile >> garbage[test];
inFile >> player[test];
getline(inFile,position[test]);
}
for(int test = 0; test < 9; test++)
{
cout << "this is garbage " << test << " - " << garbage[test] << endl;
cout << "this is player " << test << " - " << player[test] << endl;
cout << "this is position " << test << " - " << position[test] << endl;
}
cin.get(sentry);
return 0;
}