Computer Chess Club Archives


Search

Terms

Messages

Subject: OT: C++ code question.

Author: macaroni

Date: 02:03:32 11/06/03


in trying to get a book to load from a file, I have had endless trouble. I'm
using dev-cpp, heres a code snip



#include <iostream.h>
#include <fstream.h>

int main()
{
 int BookSize=0,x;
 char *BookLines[50000];
 ifstream in("SEEBook",ios::in| ios::binary);
 if (!in)
 {
  cout << "Book not found!\n";
  return 1;
 }
 while(in.getline(BookLines[BookSize],120))
 {
  BookSize++;
 }
 in.close();
 cin >> x;
 return 0;
}

the program compiles quite happly, and then 'causes an illegal operation', all I
want it to do is load the file line by line into BookLines. Each line,
incrementing BookSize so it puts it into the next slot. Any idea's what is
wrong. Could it be the computer?
cheers
tor



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.