Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 1229 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is PRIu64 in C?

#1
I am new to C and I am confronted with:

#include <stdio.h>
#include <inttypes.h>

int main(void)
{
uint64_t foo = 10;
printf("foo is equal to %" PRIu64 "!\n", foo);

return 0;
}
And it works! I don't understand why. Can somebody help me about this?
Reply

#2
[`PRIu64`](

[To see links please register here]

) is a format specifier, introduced in C99, for printing `uint64_t`, where `uint64_t` is (from linked reference page):

>unsigned integer type with width of ... 64 bits respectively
(provided only if the implementation directly supports the type)

`PRIu64` is a string (literal), for example the following:

printf("%s\n", PRIu64);

prints `llu` on my machine. Adjacent string literals are concatenated, from section _6.4.5 String literals_ of the C99 standard:

>In translation phase 6, **the multibyte character sequences specified by any sequence of adjacent character and wide string literal tokens are concatenated into a single multibyte character sequence**. If any of the tokens are wide string literal tokens, the resulting multibyte character sequence is treated as a wide string literal; otherwise, it is treated as a character string literal.

This means:

printf("foo is equal to %" PRIu64 "!\n", foo);

(on my machine) is the same as:

printf("foo is equal to %llu!\n", foo);

See

[To see links please register here]

.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through