Am 24.08.2013 20:33, schrieb Allin Cottrell:
On Sat, 24 Aug 2013, Sven Schreiber wrote:
> it seems that sscanf() doesn't distinguish between \t and \n:
> sprintf sc "one \t two \t three \n nextline"
Not really. As in C, the "%s" conversion (a) skips leading white
space and (b), once started, stops as soon as white space is
encountered. To grab a string that contains white space via sscanf
you have to get fancier -- using "%", where the brackets enclose
either (a set of characters to accept) or (a set to reject, preceded
by '^'). E.g.
ah ok, thanks!
sscanf(sc, "%[^\n]\n%s", check1, check2)
gives check1 = "one two three".
Or more precisely/pedantically, it comes with a trailing space: "one
two three ".