TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Roy McNeill
from: Nhan Tran
date: 1994-12-07 09:42:16
subject: C and octal

-=> Quoting Roy McNeill to all <=-

 RM> /* c version */
 RM> sscanf(s, "%i %i %i", &l,&m,&n);

 RM> because C treats numbers with leading zeroes as base 8 numbers.

 RM> kludgy. Am I missing something obvious? Is there an elegant way to
 RM> get C or C++ to read 0400 as 400dec instead of 256dec?

sscanf(s, "%d %d %d", &l, &m, &n);

i will convert a number according to the bases, d will convert a decimal
number. There are some subtle differences between scanf and printf
formatting characters.

Cheers,
Nhan


--- GEcho 1.11+

* Origin: The InterACTive BBS - Canberra ACT - (06) 239-7311 (3:620/243)
SEEN-BY: 50/99 54/54 620/243 250 252 262 623/630 624/50 711/401 409 410 430
SEEN-BY: 711/510 807 808 809 932 934 942 712/623 713/888 714/906 800/1
@PATH: 620/243 54/54 711/808 809 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™.