cutler@reed.UUCP (Steven J. Russell) (06/25/91)
I'm having problems using sprintf to convert a float into a string on the Mac Plus. I am developing the program on a Mac II, but when I tested the program on the Mac + it died. I'm using Think C, and the code is like this result = sprintf(c, " %f", f); s = CtoPstr(c); SetIText(item, s); Basically, the text goes into a dialog box. All of the variables are declared properly, i.e. double f; char *s, *c; ... Does anybody have any hints? Is there a better way of doing this without using sprintf()? Also, I AM using the sprintf() in the "ANSI" library, not the "ANSI-881", and I don't have the 68881 code generation option checked. Steven Russell cutler@reed.edu -- Steven J. Russell "Shut up! Shut up! I don't wanna hear your mouth!" -- Anthrax UUCP: ...!tektronix!reed!cutler
nick@cs.ed.ac.uk (Nick Rothwell) (06/26/91)
In article <16532@reed.UUCP>, cutler@reed.UUCP (Steven J. Russell) writes: > result = sprintf(c, " %f", f); > s = CtoPstr(c); > SetIText(item, s); (i) I don't see any store allocation for `c'. (ii) I thought CtoPstr worked in-place rather than returning a result. In fact, it would have to (see (i)). Nick. -- Nick Rothwell, Laboratory for Foundations of Computer Science, Edinburgh. nick@lfcs.ed.ac.uk <Atlantic Ocean>!mcsun!ukc!lfcs!nick ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ <-- WEST VIEWING ROOM EAST VIEWING ROOM -->