I had this program working a while ago but I recently came back to look at it for another project I am working on and now I am getting errors while trying to use getline()
The other file is just a text file that has the player's name, their position and other data about them as such:
Bill Quarter_Back 70 0 8754 0 573
before adding :: infront of the getline function I was getting the error
error: no matching function for call to ‘getline(std::ifstream&, int&, char)’
getline(input, p[i].position, ' '); "
and I don't know why.
Here's the code:
#include <iostream>
#include <fstream>
#include <string>
struct player{
  int position, touchDowns, catches, passingYards, recievingYards, rushingYards;
  std::string name;
};
using namespace std;
void printPlayer(player p[], ifstream &input);
void createArray(player p[], ifstream &input);
int main() {
    ifstream input;
    player p[10];
    int choice;
    while(choice != 99){
      cout << "Select one of the following options: " << "1: To print a player's data\n2: To print the entire data\n3: To update a player's touch downs\n4: To update a player's number of catches\n5: To update a player's passing yards\n6: To update a player's receiving yards\n7: To update a player's rushing yards\99: To quit the program" <<endl;
      cin >> choice;
      switch (choice){
        case 1:
        printPlayer(p, input);
        
      }
      if(choice == 99){
        break;
      }
    }
    return 0;
}
void createArray(player p[], ifstream &input){
  for(int i =0;i < 10; i++){
    getline(input, p[i].name, ' ');
    getline(input, p[i].position, ' ');
    getline(input, p[i].touchDowns, ' ');
    getline(input, p[i].catches, ' ');
    getline(input, p[i].passingYards, ' ');
    getline(input, p[i].recievingYards);
    getline(input, p[i].rushingYards);
  }
}
void printPlayer(player p[], ifstream &input){
  int wantedPlayer;
  string guyname;
  cout << "Enter players name: ";
  cin >> wantedPlayer;
  cout << endl;
  for(int i =0; i < 10; i++){
    guyname = p[i].name;
      cout << p[i].name << " " << p[i].position << " " << p[i].touchDowns << " " << p[i].catches << " " << p[i].passingYards << " " << p[i].recievingYards << " " << p[i].rushingYards << "\n" << endl;
  }
}
 
     
    