1.  
  2.  
  3.  
  4. #include <string>
  5. #include <vector>
  6. #include <iostream>
  7. #include <fstream>
  8. using namespace std;
  9.  
  10.  
  11. class player
  12. {
  13. private:
  14. string last_name;
  15. string first_name;
  16. vector <int> score;
  17.  
  18. public:
  19.  
  20. string get_last_name();
  21. void set_last_name( string n_l_name);
  22.  
  23. string get_first_name();
  24. void set_first_name ( string n_f_name);
  25.  
  26. vector <int> get_score();
  27. void set_score ( vector <int> n_score);
  28.  
  29. }
  30. string player::get_last_name()
  31. {
  32. return last_name;
  33. }
  34.  
  35. void player::set_last_name( string n_l_name)
  36. {
  37. last_name = n_l_name;
  38. }
  39.  
  40. string player::get_first_name()
  41. {
  42. return first_name;
  43. }
  44.  
  45. void player::set_first_name( string n_f_name)
  46. {
  47. first_name = n_f_name;
  48. }
  49.  
  50. vector <int> player::get_score()
  51. {
  52. return score;
  53. }
  54.  
  55. void player::set_score( vector< int > n_score)
  56. {
  57. for ( int i=0; i< n_score.size() ;i++)
  58. {
  59. score.push_back( n_score[i]);
  60. }
  61. }
  62.  
  63.  
  64.  
  65. int main( int argc, char* argv[])
  66. {
  67. //Intput the file using command line argv[1].
  68. ifstream read_file(argv[1]);
  69. if ( !read_file )
  70. {
  71. cerr << "Can't open " << argv[1] << " to read \n";
  72. exit(1);
  73. }
  74.  
  75. string temp_last_name;
  76.  
  77. string temp_first_name;
  78.  
  79. int temp_score;
  80.  
  81. vector < int > vec_temp_score;
  82.  
  83. vector < player > vec_players;
  84.  
  85. player temp_player;
  86.  
  87. while ( !read_file.eof())
  88. {
  89. read_file >> temp_first_name >> temp_last_name; //read_in the last, first names.
  90. for ( int i=0; i< 20;i++) // loop through the integers(scores) and read into the vector.
  91. {
  92. read_file >> temp_score;
  93. vec_temp_score.push_back(temp_score);
  94. }
  95. temp_player.set_last_name( temp_last_name);
  96. temp_player.set_first_name( temp_first_name);
  97. temp_player.set_score( vec_temp_score);
  98.  
  99. vec_players.push_back(temp_player);
  100. }
  101.  
  102. //Out file the output using command line argv[2].
  103. ofstream out_file(argv[2]);
  104. if ( !out_file )
  105. {
  106. cerr << "Can't open " << argv[2] << " to read \n";
  107. exit(1);
  108. }
  109.  
  110. }
  111.