int Value;
if (sscanf(Line, "%s%s%d", Type, Command, &Value) == EOF)
{
....
Now, if Value can''t take 800 from Line then I figured I would return a string by makeing %d, %s and removing the &. However all I get back in that case is high ASCII. I am puzzled..
Anyone see a obvious error I missed in these last 8 hours?
scanf error just made my day
Ok, I have read data from a text file and place it in char Line[100].
Line looks like this
"set resx 800"
I then use the following sscanf line to break it up into it''s words.
------------------------------------------------------------I wrote the best video game ever, then I woke up...
ISTR sscanf returns the number of items successfully read. So you probably want:
if(sscanf(Line, "%s%s%d", Type, Command, &Value) == 3)
December 21, 2000 12:11 PM
I think you are basically on the right track.
One thing, sscanf returns the number of successfully converted
arguments (so, you should test for != 3 would mean all args weren''t converted, not for EOF [which only applies to scanf]).
Enjoy
One thing, sscanf returns the number of successfully converted
arguments (so, you should test for != 3 would mean all args weren''t converted, not for EOF [which only applies to scanf]).
Enjoy
Nope, still get 0x817a379c or high ASCII..
------------------------------------------------------------I wrote the best video game ever, then I woke up...
AH! Found the bug.
For some reason sscanf is not reading the Line..
For some reason sscanf is not reading the Line..
------------------------------------------------------------I wrote the best video game ever, then I woke up...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement