I have an input string of the form
char *s = "one.two three"
and I want to separate it into 3 string variables.
I’m doing
sscanf(s, "%s.%s %s", one, two, three);
but it’s reading in “one.two” as the string for variable one. How do I handle the “.” and the whitespace with sscanf?
The
%sspecifier only stops for a space. Try something like:Interestingly, it’s likely impossible to produce an acceptable input for
"%s.%s %s"since%sonly stops for a space yet a.must immediately follow it.