johns@macondo.Caltech.Edu (John Salmon) (02/18/89)
I have an old (March 87) draft of the standard which says
in Sec. 4.9.6.2 The fscanf function, paragraph 8:
"...A white-space directive fails if no white-space can be found."
K&R 2nd edition says that "white-space directives are ignored"
Which is correct? Is count set to 0 or 1 by:
count = sscanf("10", " %d", &i);
Thanks,
John Salmon
johns@wega.caltech.edugwyn@smoke.BRL.MIL (Doug Gwyn ) (02/21/89)
In article <9641@cit-vax.Caltech.Edu> johns@wega.caltech.edu.UUCP (John Salmon) writes: >Which is correct? Is count set to 0 or 1 by: > count = sscanf("10", " %d", &i); It's set to 1. Generally, the properties of fprintf and fscanf in the proposed standard were checked against existing UNIX System V behavior, since AT&T would have vigorously protested having to change this existing behavior.
johns@tybalt.caltech.edu (John Salmon) (02/22/89)
I have an old (March 87) draft of the standard which says
in Sec. 4.9.6.2 The fscanf function, paragraph 8:
"...A white-space directive fails if no white-space can be found."
K&R 2nd edition says that "white-space directives are ignored"
Which is correct? Is count set to 0 or 1 by:
count = sscanf("10", " %d", &i);
Thanks,
John Salmon
johns@tybalt.caltech.edu
johns@tybalt.caltech.edu.UUCPgwyn@smoke.BRL.MIL (Doug Gwyn ) (02/23/89)
In article <9676@cit-vax.Caltech.Edu> johns@tybalt.caltech.edu.UUCP (John Salmon) writes: >"...A white-space directive fails if no white-space can be found." >K&R 2nd edition says that "white-space directives are ignored" >Which is correct? Neither. A white-space directive is executed by reading input up to the first non-white-space character (which remains unread), or until no more characters can be read. It never fails, by definition. > Is count set to 0 or 1 by: > count = sscanf("10", " %d", &i); sscanf returns 1 in this case.