Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!rutgers!husc6!cmcl2!brl-adm!adm!franco@MIKEY.BBN.COM From: franco@MIKEY.BBN.COM (Frank A. Lonigro) Newsgroups: comp.unix.wizards Subject: addendum to scanf quiz winner!!! Message-ID: <8547@brl-adm.ARPA> Date: Wed, 29-Jul-87 11:36:04 EDT Article-I.D.: brl-adm.8547 Posted: Wed Jul 29 11:36:04 1987 Date-Received: Fri, 31-Jul-87 04:33:41 EDT Sender: news@brl-adm.ARPA Lines: 29 I'm afraid I was a little premature in my previous statement that the winner was actually a loser. Let me clarify this. I said that the 'scanf' statement scanf("%s %[^#] %*c %[^\n]", s1, s2, s3); ^^^ was a loser because it restricted the fact that a newline could not appear in the final string except at the end of it. Well it seem that if you use this statement to read from the terminal, this is the only way it will work. What I mean by work is that if one wishes to print out or process the resulting s1 s2 and s3 strings immediately after reading, this is the format of the scanf statement one should use. But on the other hand, if one is not using the 'scanf' to read from the terminal but is using it to scan a string as in char msg[] = "one two three # four \nfive six\n"; sscanf(msg, "%s %[^#] %*c %[^\n]", s1, s2, s3); then you won't get the result you want, ie.. include all chars except NULL. The 'scanf' statement one should use is: char msg[] = "one two three # four \nfive six\n"; sscanf(msg, "%s %[^#] %*c %[\001-\177]", s1, s2, s3); Sorry for the screw up and for the multiple messages. thanks for reading, -franco%mikey.bbn.com@relay.cs.net