Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!bally!siva From: siva@bally.Bally.COM (Siva Chelliah) Newsgroups: comp.lang.c Subject: sprintf badness Keywords: sprintf, sscanf Message-ID: <473@bally.Bally.COM> Date: 20 Jan 91 21:00:57 GMT Distribution: usa Organization: Bally Mfg. - Reno, Nevada Lines: 24 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