On Sat, 24 Aug 2013, Sven Schreiber wrote:
it seems that sscanf() doesn't distinguish between \t and \n:
<hansl>
sprintf sc "one \t two \t three \n nextline"
string scheck = ""
sscanf(sc,"%s\n%s",scheck,sc)
print scheck
</hansl>
Looks like a bug to me, no?
(scheck has value "one" after running the above)
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.
sscanf(sc, "%[^\n]\n%s", check1, check2)
gives check1 = "one two three".
Allin