FORDE@vm.poly.edu (02/01/91)
int var1=1; float var2=2.3; printf("%d %f:n",var1,var2); results in: 1 %f Can anyone tell me why this is happening. I'm using Lattice C 5.10.
dewolfe@ug.cs.dal.ca (Colin DeWolfe) (02/01/91)
In article <91031.171403FORDE@vm.poly.edu> FORDE@vm.poly.edu writes: > > int var1=1; > float var2=2.3; > > printf("%d %f:n",var1,var2); > > results in: > > 1 %f > >Can anyone tell me why this is happening. I'm using Lattice C 5.10. You're linking with the wring library. When you use floats and such, use lcm.lib (or lcm881.lib depending on your math mode) instead of lc.lib or if you're doing "lc -L file", change it to "lc -Lm (or -Lm881) file" -- Colin DeWolfe dewolfe@ug.cs.dal.ca
peterk@cbmger.UUCP (Peter Kittel GERMANY) (02/02/91)
In article <91031.171403FORDE@vm.poly.edu> FORDE@vm.poly.edu writes: > > int var1=1; > float var2=2.3; > > printf("%d %f:n",var1,var2); > > results in: > > 1 %f > >Can anyone tell me why this is happening. I'm using Lattice C 5.10. I'm sure you forgot to link with a floating-point library, like lcm.lib or some such. Check your BLink command. -- Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions... Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk
aoe@hpfcso.HP.COM (Alexander Elkins) (02/02/91)
In article <91031.171403FORDE@vm.poly.edu> FORDE@vm.poly.edu writes: > > int var1=1; > float var2=2.3; > > printf("%d %f:n",var1,var2); > > results in: > > 1 %f > >Can anyone tell me why this is happening. I'm using Lattice C 5.10. You'll be using the printf() defined in amiga.lib. That version doesn't handle %f or %d and a number of other capabilities of the printf() we all know and love to use. Use "#include <stdio.h>" and "fprintf(stdout,"%d %f:n",var1,var2);" to get the result you expect. - Alexander Elkins (aoe@hpfiaoe.fc.hp.com)
dac@prolix.ccadfa.oz.au (Andrew Clayton) (02/02/91)
In article <1991Feb1.050338.22222@cs.dal.ca>, Colin DeWolfe writes: > In article <91031.171403FORDE@vm.poly.edu> FORDE@vm.poly.edu writes: > > > > int var1=1; > > float var2=2.3; > > > > printf("%d %f:n",var1,var2); > > > > results in: > > > > 1 %f > > > >Can anyone tell me why this is happening. I'm using Lattice C 5.10. > > You're linking with the wring library. When you use floats and such, > use lcm.lib (or lcm881.lib depending on your math mode) instead of lc.lib It's better if you link with the write library, rather than the wring one. Wread Write Wring? ;^) (Yells of OFF TOPIC.) Followup to not.on.this.network
d87-khd@sm.luth.se (Karl-Gunnar Hultland) (02/05/91)
aoe@hpfcso.HP.COM (Alexander Elkins) writes: >In article <91031.171403FORDE@vm.poly.edu> FORDE@vm.poly.edu writes: >> >> int var1=1; >> float var2=2.3; >> >> printf("%d %f:n",var1,var2); >> >> results in: >> >> 1 %f >> >>Can anyone tell me why this is happening. I'm using Lattice C 5.10. >You'll be using the printf() defined in amiga.lib. That version doesn't handle >%f or %d and a number of other capabilities of the printf() we all know and >love to use. Use "#include <stdio.h>" and >"fprintf(stdout,"%d %f:n",var1,var2);" to get the result you expect. Or just #include <stdio.h> #undef printf Karl -- // // // \\ // // \\ // \\ // Karl Hultland,(d87-khd@sm.luth.se) \X/ \X/ \X/ University of Lulea,Sweden 500 2000 3000 I have called this principle, by which each slight variation, if useful, is preserved, by the term of Natural Selection. /C. Darwin
hwr@pilhuhn.ka.sub.org (Heiko W.Rupp) (02/06/91)
Organization: Not an Organization In article <91031.171403FORDE@vm.poly.edu>, FORDE@vm.poly.edu writes: > > int var1=1; > float var2=2.3; > > printf("%d %f:n",var1,var2); > > results in: > > 1 %f > >Can anyone tell me why this is happening. I'm using Lattice C 5.10. I don't know much about SAS C (I'm using Atzec 3.6a), but you should explicitly link with the math library before standard C-library (amiga.lib). As Floating-point-code is larger than integer-code and floats are not often used, standard library-code is for integers and you have explicitly to say, that you want the float-code. -Heiko P.S.: Consult your manual about printf("%f"); -- Heiko W.Rupp, Gerwigstr.5, D-7500 Karlsruhe 1 | hwr@pilhuhn.ka.sub.org Tel: +49 7021 693642 (voice only) | uk85@dkauni2.bitnet Fresst Scheisse, Miliarden von Fliegen koennen nicht irren !
jap@convex.cl.msu.edu (Joe Porkka) (02/06/91)
hwr@pilhuhn.ka.sub.org (Heiko W.Rupp) writes: >Organization: Not an Organization >In article <91031.171403FORDE@vm.poly.edu>, FORDE@vm.poly.edu writes: >> >> int var1=1; >> float var2=2.3; >> >> printf("%d %f:n",var1,var2); >> >> results in: >> >> 1 %f >> >>Can anyone tell me why this is happening. I'm using Lattice C 5.10. >I don't know much about SAS C (I'm using Atzec 3.6a), but you should >explicitly link with the math library before standard C-library (amiga.lib). Since the "%f" gets printed, the problem is more likly that you are linking AMIGA.LIB before lc.lib. There is a "printf()" defined in amiga.lib but it does not understand floats. So... link with lc.lib then amiga.lib.
m0154@tnc.UUCP (GUY GARNETT) (02/08/91)
In article <1419@tau.sm.luth.se> d87-khd@sm.luth.se (Karl-Gunnar Hultland) writes: >-- // > // > // \\ // > // \\ // \\ // Karl Hultland,(d87-khd@sm.luth.se) >\X/ \X/ \X/ University of Lulea,Sweden >500 2000 3000 > >I have called this principle, by which each slight variation, >if useful, is preserved, by the term of Natural Selection. /C. Darwin > But ... ... but where is the 1000 ... ... how quickly they forget ... *** THE A1000 IS NOT YET EXTINCT *** *** RUMORS TO THE CONTRARY HAVE *** *** BEEN VASTLY OVERSTATED! *** ... thank you :) ... Wildstar An Amiga (1000) owner for 5 years ... ... two days ... ... and 4 hours (tho if you want to give me a 3000, I won't complain)