The scanf family of functions includes the functions scanf, fscanf, and sscanf. When reading in floating-point numbers, these functions convert the strings INFINITY, INF, and NAN (in uppercase, lowercase, or mixed case) to the corresponding floating-point value. The sign of the value is determined by the format specification.

Given a string that consists of NAN, INF, or INFINITY, followed by other characters, the scanf functions read in only the NaN or infinity value, and consider the rest of the string to be a second input field. For example, Nancy would be scanned as two fields, Nan and cy.

Note: In the case of a string that begins with INF, the functions check the fourth letter. If that letter is not I (in uppercase or lowercase), INF is read and converted and the rest of the string is left for the next format specification. If the fourth letter is I, the functions continue to scan for the full INFINITY string. If the string is other than INFINITY, the entire string is discarded.