Hello,
Does the following code invoke undefined behavior?
#include <stdio.h>
int main(void)
{
unsigned short int u = 42;
printf("%u\n", u);
return 0;
}
gcc doesn't seem to mind.
$ gcc -Wall -Wextra -std=c89 -pedantic zzz.c
$ ./a.out
42
Is it mandatory to add the 'h' length modifier in the format string?
unsigned short int u = 42;
printf("%hu\n", u);
Regards.
Does the following code invoke undefined behavior?
#include <stdio.h>
int main(void)
{
unsigned short int u = 42;
printf("%u\n", u);
return 0;
}
gcc doesn't seem to mind.
$ gcc -Wall -Wextra -std=c89 -pedantic zzz.c
$ ./a.out
42
Is it mandatory to add the 'h' length modifier in the format string?
unsigned short int u = 42;
printf("%hu\n", u);
Regards.
Comment