I think the Postel Act ("to be conservative in what you do, be liberal in what you accept from others") also applies here. Do not write down your tests to require matching for each character, to consider an implementation printf()that will work.
Instead, make it a higher level; analyze the output of the text using printf()the expected data type and compare it with the value of this type.
Ie, if the print is "2.25", parse the text (using strtod()either the equivalent) and compare with the actual number 2.25, rather than the literal text string "2.25".
source
share