mardi 1 août 2017

Cannot find proper '>>' conversion

A small chunk of my program. The issue is the "string ID[4];" which the compiler doesn't accept, so it gives me an error on "infile >> array[i].ID;". Does anyone have any solutions? :)

//Beginning program
struct Record
{
    std::string ID[4];
    float income;
    int members;
};

void optionA(Record array[]);
void optionB(Record array[]);
void optionC(Record array[]);
void optionD(Record array[]);
void optionE(Record array[]);

int main()
{
ifstream infile;
ofstream outfile;

char decision;
char ans = 'Y';
Record array[16];
int i = 0;
infile.open("C:Temp\\Lab8\\Lab8in.txt");
if (!infile || !outfile)
{
    cout << "File cannot be opened. Terminating program." << endl;
    return 0;
}
while (!infile.eof())
{
    infile >> array[i].ID;
    infile >> array[i].income;
    infile >> array[i].members;
    i++;
}

Aucun commentaire:

Enregistrer un commentaire