I'm looking to read in several data points from the user via stdin and scanf().
However, if the user wishes to indicate invalid data, denoted by a *, this would violated the expected format (%f, %d, etc), and as I understand it, cause scanf() to return an error.
The way I conceived to deal with this is to read the input from stdin as a series of strings, check these for *, and then deal with that accodingly. This seems very naive and messy, and I was wondering if there was a cleaner way to accomplish this.
Please note, I am working in a very limited environment, so POSIX/3rd party solutions will not apply. ANSI C only :(
fgetsorgetlineto read the input into a buffer and then process that a few time to see how it works, but it will get complicated and slow in a hurry unless there are only a limited number of possible correct parsings.fgets(). (OK, maybe two,strchr()applies as well.)scanf. c-faq.com/stdio/scanfprobs.html