Mail Archives: djgpp/2000/09/23/08:00:34

From: raynee AT my-deja DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: GPF caused by string functions...
Date: Sat, 23 Sep 2000 11:35:18 GMT
Organization: - Before you buy.
Lines: 51
Message-ID: <8qi4hm$ism$>
X-Article-Creation-Date: Sat Sep 23 11:35:18 2000 GMT
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
X-Http-Proxy: 1.1 (NetCache 4.1R5D2), 1.1 (Squid/1.1.22) for client,
X-MyDeja-Info: XMYDJUIDraynee
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I am trying to get some string functions to work as part of the
interface for my program. I am using ScreenPutString to write to the
screen and my code appears to work when I call my centrestring()
function once it works okay. A second call, however, causes a General
Protection fault no matter how I specify my parameters. The code that I
am using is:

/* Include standard DJGPP libraries */
#include <pc.h>
#include <conio.h>
#include <string.h>

/*  putstring ( str, fg, bg, col, row )
    Calls the DJGPP function ScreenPutString from libc.a */
int putstring ( char *str, int fg, int bg, int col, int row ) {
    ScreenPutString(str, (bg<<4) | fg, col, row);

/*  centrestring ( str, fg, bg, row, col, width )
    Writes the specified string to the screen, centring it as it does */
int centrestring ( char *str, int fg, int bg, int col, int row, int
width ) {
    char buf[81], spacer[81];
    int i,j,k;
    i = strlen(str);
    j = (width - i) / 2;
    memset(buf,' ',--j);
    memset(spacer,' ',(width-i-j));
    buf[width] = 0;

/*  main
    Tests the code */
int main ( void ) {
    centrestring("Just one line is okay",WHITE,BLUE,0,0,80);
    centrestring("This should work.",WHITE,BLUE,0,1,80);

If anyone has any ideas as to why this doesn't work I would appreciate
any feedback.



Sent via
Before you buy.

- Raw text -

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