Common mistakes in creating format strings include
- Using using invalid conversion specifiers
- Using using a length modifier on an incorrect specifier
- Mismatching mismatching the argument and conversion specifier type
- Using using invalid character classes
Wiki Markup |
---|
The following are C99 -compliant conversion specifiers \[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\]. Using any other specifier may result in [undefined behavior|BB. Definitions#undefined behavior]. |
...
Only some of the conversion specifiers are able to can correctly take a length modifier. Using a length modifier on any specifier other than the following may result in undefined behavior.
...
Character class ranges must also be properly specified with a hyphen in between two printable characters. The two following lines are both properly specified. The first accepts any character from a -to z, inclusive, while the second accepts anything that is not a -to z, inclusive.
Code Block |
---|
[a-z] [^a-z] |
Note that the range is in terms of character code values, and on an EBCDIC platform it will include some non-alphabetic nonalphabetic codes. Consequently, the isalpha()
function should be used to verify the input.
...