Keeps returning 0

Keeps returning 0 and I'm not sure what to do

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

void displayTeams(string);
void displayWorldSeriesWinners(string);
string team;


int main()
{
void displayTeams(string);
// Display the names of the teams listed in the "Teams.txt" file.
displayTeams("Teams.txt");

cout << "\nPlease enter the name of one of the teams on the ";
cout << "list to see how many World Series they have won: ";
getline(cin, team);
void displayWorldSeriesWinners(string);


system("pause");
return 0;
}

// ********************************************************
// The displayTeams function reads data from a file and *
// displays it on the screen. *
// ********************************************************
void displayTeams(string Teams)
{
string data; // To hold the data from the file
int count = 0; // Counter variable for the columns

// File stream object to read data from a file
ifstream inputFile;
// Open the file.
inputFile.open(Teams);
// If the file successfully opened, process it.
if (inputFile)
{
// Display a description of the file's contents.
cout << "The following teams have won "
<< "the World Series at least once:\n\n";
while (getline(inputFile, data))
{
// Format output to be left-aligned
// with a field width of 24 characters.
cout << left << setw(24);
// Display an item from the file.
cout << data;
// Increment the column counter variable.
count++;
// Determine if three columns have been displayed.
if (count >= 3)
{
// If so, end the line and begin a new row of output.
cout << endl;
// Reset the column counter variable to zero.
count = 0;
}
}
// Set the alignment back to the default setting.
cout << right << endl;
}
else
{
// Display an error message.
cout << "Error opening the file.\n";

// Exit the program.
exit(0);
}
string temp_string, team;
int team_count, number;
team_count = 0;
number = 0;
ifstream infile("WorldSeriesWinners.txt");
cout << "Choose a team from the list to see how many times they have won the world series champion \n";
getline(cin, team);
while (infile >> temp_string)
{
if (temp_string == team)
{
number++;
}
team_count++;
}
cout << "The " << team << " has won the World Series Champion " << number << " times since 1903.\n";

system("pause");
return 0;
}
1
2
3
int main()
{
void displayTeams(string);


that is wrong.

also in the last line you are returning 0 from a function which is supposed to return nothing
If I remove the void and string I get an error of too few arguments
1
2
3
4
5
6
7
8
9
10
void displayTeams(string); //function declaration
void displayWorldSeriesWinners(string);
string team;


int main()
{
void displayTeams(string); //function re-declaration inside main? ERROR.

displayTeams("Teams.txt");
Last edited on
Topic archived. No new replies allowed.