sprintf badness
Siva Chelliah
siva at bally.Bally.COM
Mon Jan 21 08:00:57 AEST 1991
Hi,
I am running into problems when I mix floats and integers in sprintf.
1. How it is handled normally ? [Do not use "f" in sprintf ?
multiply by 10 and divide by 10 ?]
Thanks .
siva
main ()
{
char buf[90];
int i,j;
double k;
sprintf(buf,"%.4d%07.2f%.4d",45,445.34,1234);
printf("buf = %s\n",buf);
sscanf(buf,"%4d%7f%4d",&i,&k,&j);
printf("i = %d j = %d k= %7.2f",i,j,k);
}
------------ output of the above program ----------------
buf = 00450445.341234
i = 45 j = 1234 k= 8840025108807417000.00
More information about the Comp.lang.c
mailing list