C - scanf unsigned char

I am trying to use scanf() to read the unsigned char value with %hhu , but the compiler returned me:

 error: unknown conversion type character 'h' in format [-Werror=format]| // line 3 error: too many arguments for format [-Werror=format-extra-args]| // line 3 

With the following code:

 printf("Enter a number: "); unsigned char nb; scanf("%hhu", &nb); // line 3 printf("Number: %u\n", nb); return (nb); 
+6
source share

All Articles