Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: OT: C++ code question.

Author: Daniel Clausen

Date: 09:37:52 11/07/03

Go up one level in this thread


On November 07, 2003 at 12:26:28, Bo Persson wrote:

>On November 06, 2003 at 18:46:10, Daniel Clausen wrote:
>
>
>>I have no clue why your compiler doesn't like 'std::string BookLines[5000];' It
>>would help if you'd post the exact compiler output.
>>
>
>First, it's not [5000], but [50000].

The programs always used 50000. Someone simply forgot a zero in a quoted text,
big deal. :)



>Second, declaring a local array of 50000 elements is dangerously close to
>causing a stack overflow at run-time.

Goot point.

I wouldn't do that on the stack, be it 5000 or 50000 lines. Allocating it via
malloc/free or new/delete would be safer when it has to be pure C. In C++ I'd
use list/vector class from the STL, as I suggested in another post.

If the situation allows it, it would be the simplest to process the lines
directly after reading and throw them away afterwards.

Sargon



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.