| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | C and octal |
Hi Paul (delayed answer, bugger of a month) RM> char *s = "1245 2330 0400"; RM> int l,m,n; RM> sscanf(s, "%i %i %i", &l,&m,&n); PE> I've never used %i before, I always use %d, and I was pretty sure PE> %d always treated the things as decimal. However, I was under the PE> impression that %i was the same as %d. Interesting. I've never used %d before. I started with Turbo C 1.0, and afai remember, %d barely got a mention there. I've used %i exclusively since then, and have just found out why %d was invented... I found my error the next day, btw. Just had to rtfm. The exact nature of the problem eluded me for a while, cos I was actually using something that looked like char *s = "0950 1245 2330"; int l,m,n; sscanf(s, "%i %X %i", &l,&m,&n); /* the %X is needed, trust me */ which produced l=0, m=950hex, n=1245. Infuriating. It was late, I was tired, it was time to do mail, so I took the lazy way out and asked here... PE> So, resorting to the ISO PE> standard (did you know you can buy this for about $70, and it is PE> an EXCELLENT reference, a must for every C programmer) how long before they print a new one? I'm not blowing seventy bucks only to find a new version has just appeared and I can burn the old one. And I'd need to get another one for C++, too (there seems to be an ANSI standard for C++ at last) PE> Use d instead of i and she'll be hunky dory. Done. All hunkys are dorys. PE> BTW, my ISO C standard is no longer in the other room. Propping up a crooked table, perhaps? Cheers, and ta (tks also to Nhan and David) --- PPoint 1.88* Origin: Silicon Heaven (3:711/934.16) SEEN-BY: 711/809 934 @PATH: 711/934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.