I can only use string objects and string functions for this exercise. When I tried to put " over " << loser. It didn't output the loser team's name first. Also, I want the scores to be arranged as winnerscore << " to " << loserscore;
Basically,
cout << winner << " over " << loser << " " << winnerscore << " " << loserscore << endl;
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cctype>
using namespace std;
int main(){
ifstream fin;
string winner, winnerscore, loser, loserscore, hey, file;
size_t pos, blank, blank2;
fin.open("C:\\Users\\leewi\\Desktop\\Computer Programs & Projects\\C++\\BentleyCIS22B\\Ex5\\Ex5.txt");
if (!fin)
{
    cout << "Can't Open File." << endl;
    exit(0);
}
while(!fin.eof()){
    getline(fin, hey);
    pos = hey.find(' ');
    winner = hey.substr(0, pos);
    if(isalpha(hey[pos+1])){
        blank = hey.find(' ');
        winner += hey.substr(pos, blank);
    }
    else if(isdigit(hey[pos+1]))
    {
        blank = hey.find(',');
        winnerscore = hey.substr(pos, blank);
    }
    if(isalpha(hey[pos+1])){
        blank = hey.find(' ');
        loser += hey.substr(pos, hey.length());
    }
    else if(isdigit(hey[pos+1]))
    {
        loserscore = hey.substr(pos, hey.length());
    }
    cout << winner << " over " << loser << " " << winnerscore << " to " << loserscore << endl;
}
fin.close();
    return 0;
}
Output I Got:
Cincinnati over   27, Buffalo  to  27, Buffalo 24
Detroit over   31, Cleve to  31, Cleveland 17
Kansas City  over  City 24, Oakland 7  31, Cleve to  31, Cleveland 17
Carolina over  City 24, Oakland 7  35, Minnes to  35, Minnesota 10
Pittsburgh over  City 24, Oakland 7  19, NY Jets  to  19, NY Jets 6
Philadelphia over  City 24, Oakland 7  31, Tampa Bay  to  31, Tampa Bay 20
Green Bay  over  City 24, Oakland 7 Bay 19, Baltimore 17  31, Tampa Bay  to  31, Tampa Bay 20
St. Lo over  City 24, Oakland 7 Bay 19, Baltimore 17 Louis 38, Houston 13  31, Tampa Bay  to  31, Tampa Bay 20
Denver over  City 24, Oakland 7 Bay 19, Baltimore 17 Louis 38, Houston 13  35, Jack to  35, Jacksonville 19
Seattle over  City 24, Oakland 7 Bay 19, Baltimore 17 Louis 38, Houston 13  20, Tenne to  20, Tennessee 13
New En over  City 24, Oakland 7 Bay 19, Baltimore 17 Louis 38, Houston 13 England 30, New Orleans 27  20, Tenne to  20, Tennessee 13
San Fr over  City 24, Oakland 7 Bay 19, Baltimore 17 Louis 38, Houston 13 England 30, New Orleans 27 Francisco 32, Arizona 20  20, Tenne to  20, Tennessee 13
Dallas over  City 24, Oakland 7 Bay 19, Baltimore 17 Louis 38, Houston 13 England 30, New Orleans 27 Francisco 32, Arizona 20  31, Wash to  31, Washington 16
 over  City 24, Oakland 7 Bay 19, Baltimore 17 Louis 38, Houston 13 England 30, New Orleans 27 Francisco 32, Arizona 20  31, Wash to  31, Washington 16
Output I Want:
Cincinnati over Buffalo 27 to 24
Detroit over Cleveland 31 to 17
Kansas City over Oakland 24 to 7
Carolina over Minnesota 35 to 10
Pittsburgh over NY Jets 19 to 6
Philadelphia over Tampa Bay 31 to 20
Green Bay over Baltimore 19 to 17
St. Louis over Houston 38 to 13
Denver over Jacksonville 35 to 19
Seattle over Tennessee 20 to 13
New England over New Orleans 30 to 27
San Francisco over Arizona 32 to 20
Dallas over Washington 31 to 16
 
     
    