![]() |
| ||
| General Protection Exception Error Please Help! 2 Attachment(s) 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> If anyone can help it would be greatly appreciated! THANKS! |
| ||
| Re: General Protection Exception Error Please Help! What do you think is the loop condition in the following line? while (ch = Infile.peek() != EOF)[edit]Actually that whole loop is wrong. |
| ||
| Re: General Protection Exception Error Please Help! I think Borland Turbo C++ has a peek() function to peek into memory, but not into files. It looks to me that you mean to use get() to get a character from the file? I am not quite sure what you want to do after that. |
| ||
| Re: General Protection Exception Error Please Help! you should anyway use ifstream instead of fstream for reading... Omitting all errorchecking, the following will read and echo lines from a textfile: #include <fstream> |
| ||
| Re: General Protection Exception Error Please Help! Quote:
|
| ||
| Re: General Protection Exception Error Please Help! I assume you have 1 row of the array in each line of your input file, and the records (so columns in that row) are separated in some way that you can detect. What you do is you use that criterion to split up the string you read (it reads a line at a time in my code) and fill the columns of your array with the resulting data. So in pseudo code: while no readerror on read line |
| All times are GMT -4. The time now is 9:37 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC