Article View: comp.sys.mac
Article #24761Re: Re: sprintf() bug?
From: Ted Johnson
Date: Wed, 03 Feb 1988 17:18
Date: Wed, 03 Feb 1988 17:18
28 lines
1224 bytes
1224 bytes
I have found a solution to my problem. To print out floats and
integers in Lightspeed C, use the following:
char s[256];
float x= 3.3;
int y = 1;
sprintf(s, "Identity number %d: %f squared = %f",
x, (x * x));
/*To print this in a window...*/
DrawString(CtoPstr(s));
/*Or to print this in the "stdio window", do...*/
printf(s);
BTW, I tried to do this same thing using a Str255 variable instead of
a char array (in a variation of the above code), but it bombed...
Also, using DrawString() *should* also work for a DA's window (after
you first recompile the sprintf/scanf library as a DA, so that things
are referenced off of A4 instead of A5), but it doesn't. :-(
Any theories or workarounds are welcomed!
-T("All I want to do is print the value of a float in a DA's window!")ed
Technical Details
Message-ID:
<870131@hpcilzb.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!sri-unix!ctnews!pyramid!hplabs!hpcea!hpcilzb!tedjReferences:
<4VzXREy00WABE7k0FU@andrew.cmu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!sri-unix!ctnews!pyramid!hplabs!hpcea!hpcilzb!tedj From: tedj@hpcilzb.HP.COM (Ted Johnson) Newsgroups: comp.sys.mac Subject: Re: Re: sprintf() bug? Message-ID: <870131@hpcilzb.HP.COM> Date: 3 Feb 88 17:18:38 GMT References: <4VzXREy00WABE7k0FU@andrew.cmu.edu> Organization: HP Design Tech Center - Santa Clara, CA Lines: 28