franco@MIKEY.BBN.COM (Frank A. Lonigro) (07/29/87)
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
ugbinns@sunybcs.uucp (Leonard Binns) (07/31/87)
In article <8547@brl-adm.ARPA> franco@MIKEY.BBN.COM (Frank A. Lonigro) writes: >I'm afraid I was a little premature in my previous statement that the winner >was actually a loser. Let me clarify this. I also apologize for responding prematurely. I didn't realize you posted a followup (addendum) to your previous message. You changed the subject! :-) -Len