Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site boring.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!boring!jack From: jack@boring.UUCP Newsgroups: net.lang.c Subject: Re: ugliness in scanf(3) Message-ID: <6411@boring.UUCP> Date: Mon, 13-May-85 12:58:17 EDT Article-I.D.: boring.6411 Posted: Mon May 13 12:58:17 1985 Date-Received: Thu, 16-May-85 03:37:42 EDT References: <10496@brl-tgr.ARPA> <190@mplvax.UUCP> <504@umd5.UUCP> Reply-To: jack@boring.UUCP (Jack Jansen) Organization: CWI, Amsterdam Lines: 32 Apparently-To: rnews@mcvax.LOCAL Ahh, the joys of scanf..... Something I've tried about every year in the last decade but haven't got to work on any machine is the following : main() { char buf[64]; printf("Gimme string -"); scanf("%s\n", buf); ... I tried to leave the \n out, putting a space in it's place, putting a space before the %s, everything. Never, though, have I succeeded in read the *first* string from stdin with scanf (the rest is no problem). So, everytime I need to do this, I fiddle with scanf for an hour or so, and then replace the scanf by a fgets() or gets(). Question: Am I asking impossible things from scanf, or an I just soooooo very stupid that I haven't found out how to do this in many many years???? (I would prefer answers in the form 'it is impossible', but I'll settle for 'you are stupid', if accompanied by an explanation *why* I am stupid). Note that this is about reading the *first* string from stdin. After that, things are fine, as long as you're careful where to scan the \n's, etc. -- Jack Jansen, jack@mcvax.UUCP The shell is my oyster.