Monday, 9 September 2013

sscanf reading a string within a string

sscanf reading a string within a string

I have a small problem that I can't seem to fix. Say I have a string,
buffer = "1 1 X ./simple E"
And I want to extract the 2 ints, 2 chars and the filename,
sscanf(buffer, "%d %d %c %s %c, &a, &b, &c, d, &e);
printf("%d %d %c %s %c", a, b, c, d, e);
I don't get back quite what I expect. I get "11 1 X (null)". Any help
appreciated.

No comments:

Post a Comment