Re: Why is scanf such a nightmare to use?

"Guillaume Dargaud" <use_the_contact_form@xxxxxxxxxxxxxxxx> wrote in message
Whenever I try to use scanf I always get into some kind of trouble and
revert to strtok or similar finer grain functions.

I commonly copy around a variant of a "split" function, which basically
breaks up a string into a series of tokens (returned as 'char **', usually
allocated in temporary/volatile buffers which are prone to being overwritten
with later stuff).

for more advanced uses, I often use a tokenizer, which splits a string into
a set of syntax-specific tokens.

I have this string:
2010/09/02 11:03:57 Test
Where the 1st space is a space while the 2nd one is a tab.
I want to read it into two substrings, separating at the tab:
scanf(Str, "%s\t%s", DateTime, Target);
But I end up with:
Why ?!?

because there is a space...

the example string would be read as 3 substrings, not 2.