Path: utzoo!attcan!uunet!cs.utexas.edu!rutgers!cmcl2!adm!news From: stanonik@nprdc.navy.mil (Ron Stanonik) Newsgroups: comp.unix.questions Subject: Re: scanf/discarding remaining whitespace Message-ID: <24801@adm.BRL.MIL> Date: 18 Oct 90 17:10:01 GMT Sender: news@adm.BRL.MIL Lines: 16 A thought about scanf: The scanf suppression character * means "suppress one"; ie, there had better be one to suppress, otherwise the control string isn't matched and scanning stops. But if it meant "suppress zero or one", then discarding trailing whitespace (including the newline) could be accomplished with scanf("%d%*[^\n]%*c", &i); It turns out this works in 4.3bsd, though I haven't dug into scanf yet to find out why; ie, because of a bug or because * is interpreted as "zero or one". Ron Stanonik stanonik@nprdc.navy.mil