We should use “%zu” to print the variables of size_t length. We can use “%d” also to print size_t variables, it will not show any error. The correct way to print size_t variables is use of “%zu”.
In “%zu” format, z is a length modifier and u stand for unsigned type.
The following is an example to print size_t variable.
Example
#include <stdio.h> int main() { size_t a = 20; printf("The value of a : %zu", a); return 0; }
Output
The value of a : 20
In the above program, a variable of size_t length is declared and initialized with a value.
size_t a = 20;
The variables of size_t length is printed as follows −
printf("The value of a : %zu", a);