i'm struggling on trying to put the information from a csv input file to the screen... I tried one method and everything compiled but my program run screen was just all black, when i changed the filename, i got my error finding file prompt so ik it definitely` found the file, this is what i tried:
//show function
void showGoalies(Goalie *goalies, int count)
``{
cout << left;
cout << setw(15) << "Name" << setw(10) << "Team" << setw(10) << "Wins" << setw(10) << "Losses"
setw(10) << "Goals Allowed" << setw(10) << "Shots Against" << endl;
for(int i = 0; i < count; i++) {
cout << setw(15) << goalies->getName();
cout << setw(10) << goalies->getTeam();
cout << setw(10) << goalies->getWins();
cout << setw(10) << goalies->getLosses();
cout << setw(10) << goalies->getGoalsAllowed();
cout << setw(10) << goalies->getShotsAgainst();
cout << endl;
goalies++;
}
cout << setprecision(3) << (double)1796/1958 << endl;
}
I'm trying another method... here:
int showGoalies(Goalie *g_ptr, int count)
{
/* Display the headings for each column, with spacing and justification flags */
printf("%s%15s%25s%8s\n", "N", "T", "W", "L");
// Read goalie data from file using ',' as a delimiter.
for (int i = 0; i < count; i++) {
if (g_ptr->getName != 0) {
printf("%-8d%-30s%-10d%-2.2f\n",
g_ptr->getName.c_str,
g_ptr->getTeam.c_str(),
g_ptr->getWins {},
g_ptr->getLosses {});
g_ptr++;
}
/* If the goalie field is zero, then we reached the last widget, break
* out of the for loop.
*/
else
break;
}
}
but i'm receiving these errors messages and i'm unsure how to resolve it. error:
C:\STAC CP2- brennan\prog3\Program3\main.cpp||In function 'int showGoalies(Goalie*, int)':|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|130|error: invalid use of member 'std::__cxx11::string Goalie::getName() const' (did you forget the '&' ?)|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|132|error: invalid use of member 'std::__cxx11::string Goalie::getName() const' (did you forget the '&' ?)|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|133|error: invalid use of member 'std::__cxx11::string Goalie::getTeam() const' (did you forget the '&' ?)|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|134|error: expected ')' before '{' token|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|131|note: to match this '('|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|135|error: expected ')' before '{' token|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|131|note: to match this '('|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|145|warning: no return statement in function returning non-void [-Wreturn-type]|
C:\STAC CP2- brennan\prog3\Program3\main.cpp||In function 'void split(const string&, char, std::vector<std::__cxx11::basic_string<char> >&)':|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|156|warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]|
C:\STAC CP2- brennan\prog3\Program3\main.cpp|174|warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]|
||=== Build failed: 5 error(s), 3 warning(s) (0 minute(s), 0 second(s)) ===|
Aucun commentaire:
Enregistrer un commentaire