I already have code to read a text file with fscanf(), and now I need to change it so that fields that were previously free of spaces should allow spaces. The text file is mainly in the form:
title: DATA
name: DATA
etc ...
which is mostly parsed using fgets(inputLine, 512, inputFile); sscanf(inputLine, "%*s %s", &data);reading DATA fields and ignoring headers, but now some data fields should contain spaces. I still need to ignore the title and the space immediately after it, but then read the rest of the line, including spaces.
Is there any way to do this with a function sscanf()?
If not, what is the minimum change I can make to the code to handle spaces correctly?
UPDATE: I edited the question to replace fscanf () with fgets () + sscanf (), which is what my code uses. I really didn't think this was relevant when I first wrote the question, so I simplified it to fscanf ().
source
share