User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,574 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,861 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 2931 | Replies: 5
Join Date: Dec 2004
Posts: 2
Reputation: C++Newbie is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
C++Newbie C++Newbie is offline Offline
Newbie Poster

General Protection Exception Error Please Help!

  #1  
Dec 1st, 2004
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!
Attached Files
File Type: cpp Program2.cpp (857 Bytes, 0 views)
File Type: txt program2.txt (464 Bytes, 0 views)
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 10:28 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC