delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/23/16:00:22.1

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: GPF caused by string functions...
Date: Sat, 23 Sep 2000 20:53:21 +0100
Organization: Customer of Energis Squared
Lines: 18
Message-ID: <6f2qss8toorn4oqjkah80icp97suc37fvi@4ax.com>
References: <8qi4hm$ism$1 AT nnrp1 DOT deja DOT com> <969715719 DOT 727190 AT shelley DOT paradise DOT net DOT nz> <8qimkb$5n2$1 AT nnrp1 DOT deja DOT com>
NNTP-Posting-Host: modem-126.flunitrazepam.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: newsg2.svr.pol.co.uk 969738873 11454 62.136.95.254 (23 Sep 2000 19:54:33 GMT)
NNTP-Posting-Date: 23 Sep 2000 19:54:33 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Agent 1.7/32.534
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

raynee AT my-deja DOT com wrote:

> Thanks very much. I think I get it now... the problem is that I am not
> terminating buf[] with a null character.

Yep, and you fail to do this with spacer[] too.  (In case you have not
realised, buf[] and spacer[] contain random data until you
specifically load them.)

I hope this doesn't spoil your fun, but how about:

void centrestring (const char *str, int fg, int bg, 
                   int col, int row, int width) 
{
    int offset = (width - strlen(str)) / 2;
    
    putstring (str, fg, bg, col+offset, row);
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019