Hello,
On lines 70 & 75, the word col is marked as a syntax error. When I hover my mouse over, it tells me that Error: expression must have pointer-to-object type. Why am I getting this error and how do I fix it?
This program prompts & reads the file name from the user for the scores data. I am currently working on letter b which is to Load the scores data into the scores array. I am stuck. :/
col = column
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
void readfile();
void loadscores(int , int);
char upcase(char);
int main()
{
char menuChoice;
bool userNotDone = true;
int scores1,
scores2;
while (userNotDone)
{
cout << " Menu" ;
cout << "\n\n";
cout << " a. Open Files\n";
cout << " b. Load Scores";
cout << " x. Exit\n\n";
cout << " enter choice: ";
cin >> menuChoice;
switch (upcase(menuChoice))
{
case 'A': readfile();
system("pause");
break;
case 'B': loadscores(scores1, scores2);
system("pause");
break;
case 'X': cout << "exist\n";
userNotDone = false;
break;
default: cout << "error" ;
}
}
return 0;
}
void readfile()
{
fstream inData;
ofstream newFile;
ifstream readFile;
string fileName = "file Name";
srand(3);
newFile.open(fileName.c_str());
}
void loadscores(int scores1, int scores2)
{
ofstream newFile;
ifstream readFile;
string fileName;
int col = 0;
readFile.open(fileName.c_str());
readFile >> scores1[col] >> scores2[col];
while(!readFile.eof())
{
col++;
readFile >> scores1[col] >> scores2[col];
}
readFile.close();
}
char upcase(char inComing)
{
if(inComing >= 'a' && inComing <= 'z')
inComing -= 32;
return inComing;
}