I am trying to parse text containing integers in a fixed number of columns. For example, my input file might look like this:
=1=2=3 =4=5=6 =8=910
where the =
sign represents spaces in the input. An equal sign is not in the input file; I just put it there for illustrative purposes. Each integer is contained in two columns without zero padding, so the third row is not a typo: it is 8, 9, and then 10.
The sscanf
standard does not work because it first removes the spaces and then applies the format string. For example, I tried:
sscanf(buf, "%2d%2d%2d", &int1, &int2, &int3)
but he finishes parsing the third line as 8, 91 and 0.
Is there a way to do this without manually pulling a data column through the column?
source share