From: "Ian Pitt" Newsgroups: comp.os.msdos.djgpp Subject: Screen Builder Date: 20 Jun 1997 23:05:55 GMT Organization: AT&T WorldNet Services Lines: 17 Message-ID: <01bc7dce$e940bc00$c3c074cf@ian> Reply-To: "Ian Pitt" NNTP-Posting-Host: 207.116.192.195 Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01BC7DAD.623843C0" Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_01BC7DAD.623843C0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Are there any screen builders for Allegro or for JPTUI? ------=_NextPart_000_01BC7DAD.623843C0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Are there any screen builders for = Allegro or for JPTUI?

------=_NextPart_000_01BC7DAD.623843C0-- { > fin >> tmpBuffer; I'm not sure, does this really read the next 128 bytes from the input stream (including a terminating '0' character)?? > > // allocate memory to hold word > wordBuffer[n] = new char [(strlen(tmpBuffer))]; I think you'll need to allocate at least strlen(tmpBuffer) + 1 bytes here to hold the terminating '0' character of the string. > > // copy string to newly allocated space > strcpy(wordBuffer[n], tmpBuffer); > > n++; > } while(!fin.eof()); > > fin.close(); > } > > What am I missing? The DJGPP accepts this and various other attempts > such as stuffing a pointer in front of the pointer array, the only > thing I can get it to do is GPF or store only the first character Excuse my ignorance, but what do you mean with 'GPF'? > in the buffer. > I think your function above does the following inside the loop: - read 1 character from the input stream to tmpBuffer - since you're lucky, tmpBuffer is initialized with '0' characters - then you allocate strlen(tmpBuffer) = 1 bytes memory for your ptr (internally the minimum mem allocation segment will be assigned, a power of 2 number of bytes, I'm not sure what's the smallest but I think at least 2^8 = 256 bytes) - it will be assigned correctly to the next index slot in the array - the strcpy will transfer the 1 byte from tmpBuffer to the ptr - you're still lucky, because the tmpBuffer terminates with a '0' character and the wordBuffer[n] keeps more than 1 byte HTH Günther -- ~~o~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ O o __/|_ "I'm swimming, | Guenther Makulik O /* \/| I'm swimming ..." | E-Mail: makulik AT evolution DOT org \_U___/\| (Sonic Youth) | http://members.evolution.org/gmakulik/