CERT-FIO47-C_c
In this section:
Synopsis
Use valid format strings.
Enabled by default
Yes
Severity/Certainty
High/Low

Full description
The formatted output functions (fprintf() and related functions) convert, format, and print their arguments under control of a format string. The C standard outlines what format specifiers are valid in a format string. This check will find cases where the number of arguments to a format string function is invalid.
Coding standards
- CERT FIO47-C
Use valid format strings
Code examples
The following code example fails the check and will give a warning:
#include <stdio.h>
void example(int a) {
printf("%*d", a);
}
The following code example passes the check and will not give a warning about this issue:
#include <stdio.h>
void example(int a) {
printf("%*d", 5, a);
}