Iterating with sscanf

后端 未结 4 419
闹比i
闹比i 2021-01-29 08:58

I do not know much about the sscanf function, but what I am trying to do is iterate through a line of integers. Given the variable

    char *lineOfInts
         


        
4条回答
  •  星月不相逢
    2021-01-29 09:04

    Read much more about sscanf(3) and strtol(3)

    Notice that sscanf returns the number of scanned elements and accepts the %n conversion specifier (for the number of consumed char-s). Both are extremely useful in your case. And strtol manages the end pointer.

    So you could use that in a loop...

提交回复
热议问题