I have the following code
#include<stdio.h>
#include<string.h>
int main (void)
{
unsigned int pqr = 201;
unsigned int def = 113;
printf("The values are,%u,%s,%s,%u\n", pqr,"\0","\0",def);
printf("The values are,%u,%d,%d,%u\n", pqr,atoi("\0"),atoi("\0"),def);
}
The values are,201,,,113
The values are,201,0,0,113
The first printf gives me nothing if the value string is set to NULL and I used format specifier “%S”. How do I achieve the same result using format specifier %d in the second. Currently it gives “0” instead of nothing.
""is the empty string."\0"is an empty string with an additional null character. It is not the same asNULL. Passing a null pointer for thesconversion specifier is undefined behavior.You cannot.
printfwith%dconversion specification prints anintvalue; it cannot print nothing.