QP School
Using incorrect format specifiers in C - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32)
+--- Thread: Using incorrect format specifiers in C (/showthread.php?tid=5121)



Using incorrect format specifiers in C - Qomplainerz - 07-26-2023

Mismatching format specifiers with the data types can lead to undefined behavior or incorrect output.

// Incorrect
int x = 10;
printf("Value of x: %s\n", x); // Incorrect format specifier '%s' for integer

// Correct
int x = 10;
printf("Value of x: %d\n", x); // Output: Value of x: 10