Old c guys, sscanf() question..

I have this one line of code here…

linep is a char*
aaitem is a double
i is an int

if (sscanf(linep, "%lf%n", &aaitem, &i) < 1) {       // If we can NOT find a double or an int in this mess..

The comment is just my best guess at what its doing.

Is it looking for a double and an int in the string? Or is that pointer to int i something about the line index?

I ask because after this, if it is successful, I get…

linep += i;   // skip to end

And in the context of this stuff I’m wading through. It makes no sense.


-jim lee

Excellent sscanf, scanf references.

%n tells you how many characters were examined or "consumed" in decoding the double value.

Thanks! That makes what I saw in the code make WAY more sense. He's parsing out tokens. The i was the index.

-jim lee