Hello im new to daniweb and c++ and am getting a overloaded function error on my readFile function, specifically the string data type. I cant seem to pinpoint whats causing the error. Im supposed to use the function to read data from a text file in this format:
Johnson 5000
Miller 4000
Duffy 6000
Robinson 2500
Ashtony 1800
Here is my code:
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
void readFile(string listA[], int listB[]);
using namespace std;
int main()
{
int votes[5];
string politicians[5];
ifstream inFile;
readFile(politicians, votes);
return 0;
}
void readFile(string listA[], int listB[])
{
ifstream inFile;
inFile.open("politicians.txt");
int noOfPoliticians = 0;
inFile >> listA[noOfPoliticians] >> listB[noOfPoliticians];
cout << listA[noOfPoliticians] << listB[noOfPoliticians] << endl;
while (inFile && noOfPoliticians < 5)
{
noOfPoliticians++;
inFile >> listA[noOfPoliticians] >> listB[noOfPoliticians];
cout << listA[noOfPoliticians] << listB[noOfPoliticians] << endl;
}
}
the compiler doesnt find any errors if i change the string data type to char but that wont give me all the data. What am i missing?