Both the C11 and C17 standards use terms “conversion specifier” and “format specifier”. Are they synonyms? If yes, then why introducing the synonyms? If no, then what is the difference between them?
Is the term "format specifier" a synonym for term "conversion specifier"?
171 Views Asked by pmor At
3
There are 3 best solutions below
2
On
The Format Specifier only specifies the format of the conversion (ie 'f') where the Conversion Specifier means the whole Specifier (ie %*13lf).
I took the example from this answer: What is the difference between conversion specification and format specifier in C?
6
On
Independent of the standard, which is confusing looking at other answers, so just looking at the meaning of these terms in the English language, I am inclined to say
"Conversion specifier" describes the native type (int, char, double) from or to which data is converted, whereas the "format specifier" describes or includes the presentation (field length, padding).
"Format specifier" appears to just be a semi-formal term. The only normative text using the term is the
inttypes.hheadline 7.8.1, with no explanation provided of what a "format specifier" is. Thoughinttypes.hmixes the size and type/signedness into a single term, because of the nature of thestdint.htypes. It says thatdinPRId32is a conversion specifier and thenPRId32as whole is supposedly a format specifier? While fprintf/fscanf separates for example "length modifiers" and "conversion specifiers", wherelin%ldwould be the length modifier anddthe conversion specifier.The fprintf and fscanf functions define a term conversion specification, for example C17 7.21.6.1, emphasis mine:
The above is also the formal definition of the term conversion specifier. Then these functions list valid conversion specifiers as
d, i, fand so on.It would appear that "format specifier" and conversion specification mean the same thing.