Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion specifier %ju

Tags:

c

printf

scanf

In the following page, I found the code like

CERT INT15-C Use intmax_t or uintmax_t for formatted IO on programmer-defined integer types

uintmax_t temp;

if(scanf("%ju", &temp) != 1) {
   ...

I am not familiar with the "%ju" specifier. And I am not successful in finding the explanation of the "%ju" on the Internet.

Is this defined by some specific compiler environment, or generally used one?

like image 289
sevenOfNine Avatar asked Dec 04 '13 00:12

sevenOfNine


People also ask

What is %Ju in c?

%ju is just the %u (unsigned) format with a j length modifier, the latter being defined in the C99 standard as: j — Specifies that a following d , i , o , u , x , X , or n conversion specifier applies to an argument with type pointer to intmax_t or uintmax_t .

What is a conversion specifier?

Type conversion specifier. The type conversion specifier character specifies whether to interpret the corresponding argument as a character, a string, a pointer, an integer, or a floating-point number. The type character is the only required conversion specification field, and it appears after any optional fields.

What is %U in printf?

Unsigned Integer Format Specifier %u The %u format specifier is implemented for fetching values from the address of a variable having an unsigned decimal integer stored in the memory. It is used within the printf() function for printing the unsigned integer variable.

For what is the format specifier %u used?

unsigned specifier (%u) in C with Examples The format specifier is used during input and output. It is a way to tell the compiler what type of data is in a variable during taking input using scanf() or printing using printf().


1 Answers

%ju is just the %u (unsigned) format with a j length modifier, the latter being defined in the C99 standard as:

j — Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to intmax_t or uintmax_t.

like image 185
jwodder Avatar answered Oct 06 '22 23:10

jwodder