Path: utzoo!attcan!uunet!mcvax!cernvax!ethz!forty2!poole From: poole@forty2.UUCP (Simon Poole) Newsgroups: comp.os.minix Subject: What should [fs]scanf return? Message-ID: <588@forty2.UUCP> Date: 16 Jan 89 13:23:37 GMT Reply-To: poole@forty2.UUCP (Simon Poole) Organization: Exp. Physics University Zuerich Lines: 36 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",&dummy,&dummy)); ........ 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' The fixes to get the behaviour in the third row are quite simple, but is it correct? * Applies to the PC version too as far as I know. -- ---------------------------------------------------------------------------- UUCP: ...mcvax!cernvax!forty2!poole Simon Poole BITNET: K538915@CZHRZU1A ----------------------------------------------------------------------------