Xref: utzoo comp.lang.c:15656 comp.os.minix:4653 Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!csd4.milw.wisc.edu!nic.MR.NET!shamash!com50!midgard!dal From: dal@midgard.Midgard.MN.ORG (Dale Schumacher) Newsgroups: comp.lang.c,comp.os.minix Subject: Re: What should [fs]scanf return? Message-ID: <594@midgard.Midgard.MN.ORG> Date: 19 Jan 89 17:26:18 GMT References: <588@forty2.UUCP> Reply-To: dal@midgard.Midgard.MN.ORG (Dale Schumacher) Organization: The Midgard Realm, St Paul MN Lines: 29 The following question appeared in comp.os.minix recently. I thought it would get a better/faster answer in comp.lang.c, thus this crossposting. In article <588@forty2.UUCP> poole@forty2.UUCP (Simon Poole) writes: |Somehow I've got the feeling that this has been hashed thru before, but |I probably wasn't paying attention then. Consider the following code |fragment: | |........ | printf("%d\n",sscanf("123","%d",&dummy)); | printf("%d\n",sscanf("123","%*d",&dummy)); | printf("%d\n",sscanf("123:456","%d:%d",&dummy,&dummy)); | printf("%d\n",sscanf("123:456","%*d:%*d")); |........ | |What should it print? | |Minix-ST 1.1 BSD 4.2 I think it should be | | 1 1 1 | 1 -1 0 | 3 2 2 | 3 -1 0 | | |K&R first edition says (about scanf): | |'It returns as its value the number of sucessfully matched and assigned | input items'