Hello,
This is my first post. Anyway.. I am having trouble with my c++ program. My assignment is to read from a file a 2-Dimensional array. However, when attempting to do so with my code, which i'm guessing is faulty, I keep getting this error while using Borland Turbo C++ 4.5:
General Protection Exception
0x9CF7:0x4D58
Program2(1) 0x9CF:0x4D58 Processor Fault
Here is my code and I have also attached my files:
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
#include <stdlib.h>
#include <fstream.h>
#include <ctype.h>
int grade[15][6];
/********************************************************/
void fileopen()
{
char ch;
fstream Infile;
Infile.open("program2.txt", ios::in);
if (!Infile)
{
cout<<"File not found!";
}
int i=0, h=0;
while (ch = Infile.peek() != EOF)
{
Infile >> grade[i][h];
i++;
h++;
}
Infile.close();
}
/********************************************************/
int displaygrades()
{
fstream Infile;
for (int i=0; i < 15; i = i + 1) {
for(int h=0; h < 6; h = h + 1){
Infile << grade[i][h] <<"\n";
}
}
}
/********************************************************/
int main()
{
fileopen();
displaygrades();
return 0;
}
If anyone can help it would be greatly appreciated! THANKS!