Hi, I'm trying to make a program that reads a text file that contains about 4 rows of numbers and outputs the average for each row. I need help with these two errors. It is not complete but I need help on these so I can continue. Any help is appreciated. Thanks in advanced.
Error 1 error C2109: subscript requires array or pointer type line 41
Error 2 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion) line 52
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
const int MAX_CODE_SIZE = 200;
bool die(const string & msg);
int main(){
ifstream incode;
ofstream outcode;
char inputFile[30];
char outputFile[30];
cout << "Enter your input file name: ";
cin >> inputFile;
cout << endl;
incode.open(inputFile);
if (!incode){ bool die("File opening error");
cout << "Enter the name for your output file: ";
cin >> outputFile;
cout << endl;
outcode.open (outputFile);
unsigned sum = 0;
unsigned col = 0;
unsigned row = 0;
unsigned matrix = 0;
unsigned NUMBER_OF_ROWS;
unsigned NUMBER_OF_COLUMNS;
for (row=0;row < NUMBER_OF_ROWS; row++)
{
sum=0;
for (col = 0; col < NUMBER_OF_COLUMNS; col++)
sum = sum + matrix[row][col];
cout << "AVERAGE OF ROW IS " << row + 1 / NUMBER_OF_COLUMNS << endl;
incode.close();
outcode.close();
return 0;
}
} }
bool die(const string & msg) {
cout << "FATAL ERROR " << msg <<endl;
exit(EXIT_FAILURE);
}