delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/09/23/13:42:03

To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Strange behavior in djgpp/go32
Date: Wed, 23 Sep 92 12:12:19 -0500
From: mll AT aio DOT jsc DOT nasa DOT gov

I have a sample program below that acts very strangely.  It seems
that if I give this program a filename with more than 3 characters
in the name portion (.out extension of the binary), the addresses of
<res> and <fov> get changed after the first call to Generate_Prefix.
 The program works fine for filenames of 3 characters or less (plis
extension).

As a reference, I am using djgpp version 1.08 that I got from
clarkson friday (i was using 1.05 until then).

any help on this one is welcome.  it sure has me puzzled.


mark

=====================================================================
Mark L. Littlefield              Intelligent Systems Department
internet: mll AT aio DOT jsc DOT nasa DOT gov 
USsnail:  Lockheed Engineering and Sciences 
          2400 Nasa Rd 1 / MC C-19            
          Houston, TX 77058-3711
====================================================================


===============< cut here >===============================


/*
 * xxxx.cc: 
 */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <pc.h>
#include <string.h>


int Generate_Prefix(int res, int fov, char *test, char *fn_t)

{
	char  ch;
/*
 * set up prefix(test, res, fov, etc.)
 */	
	strcpy(fn_t, test);
	sprintf(&ch, "%d", res);
	strncat(fn_t, &ch, 1);
	sprintf(&ch, "%d", fov);
	strncat(fn_t, &ch, 1);
	strcat(fn_t, "-");
	printf("%s   %s\n", test, fn_t);
	return(1);
}




int main()

{
	char kluge[15];
	int  res, fov;
	char fn_1[13], fn_2[13], fn_3[13], fn_4[13];
	

	ScreenClear();
	res = 1;
	fov = 1;

	printf("res = %d:%x    fov = %d:%x\n", res, &res, fov, &fov);
	kluge[0] = NULL;
	Generate_Prefix(res, fov, "2", kluge);
	printf("res = %d:%x    fov = %d:%x\n", res, &res, fov, &fov);
	printf("check: %s\n", &kluge[0]);

	res = 1;
	fov = 1;

	Generate_Prefix(res, fov, "1", &fn_1[0]);
	printf("res = %d    fov = %d\n", res, fov);
	printf("res = %d:%x    fov = %d:%x\n", res, &res, fov, &fov);
	printf("check: %s\n", &fn_1[0]);

	Generate_Prefix(res, fov, "2", &fn_2[0]);
	printf("res = %d    fov = %d\n", res, fov);
	printf("res = %d:%x    fov = %d:%x\n", res, &res, fov, &fov);
	printf("check: %s\n", &fn_2[0]);


	exit(1);
}

- Raw text -


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