3

What %qu format stands for in printf(). Know that %u is unsigned, %qu never came across. When googled found all other formats apart from %qu

msc
  • 33,420
  • 29
  • 119
  • 214
  • `%qu` = unsigned 64-bit integer (unsigned long long) – l'L'l Feb 25 '19 at 05:13
  • [Wikipedia](https://en.wikipedia.org/wiki/Printf_format_string#Length_field) says "`q` For integer types, causes printf to expect a 64-bit (quad word) integer argument. Commonly found in BSD platforms. " – Ignatius Feb 25 '19 at 05:14
  • It may be help you : https://stackoverflow.com/questions/50830312/what-is-the-purpose-of-format-specifier-qd-in-printf – msc Feb 25 '19 at 05:15
  • Then %llu stands the same i suppose the was some use %qu – Sushil Kumar Feb 25 '19 at 05:15
  • No, unsigned long longs have a minimum width rather than a fixed width. ULLs may well be 512 bits wide or even more. – paxdiablo Feb 25 '19 at 05:17
  • @SushilKumar: `%llu` = 64-bit (unsigned long long) although it allows 32-bit architectures to use it. – l'L'l Feb 25 '19 at 05:22

2 Answers2

4

It's not standard, it's used in some Unixes (mostly BSD) to represent an unsigned quadword (64 bits). Hence the q as a type modifier, like l for long.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
2

It's an old BSDism that should not be used, from before C had long long types. From the FreeBSD man page for printf, you can see that, at least on FreeBSD, it was corresponding to the nonstandard type u_quad_t, and that it's marked as deprecated. I'm not sure if u_quad_t was ever formally specified as being unsigned long long, but the portable replacement is using the ll modifier with type unsigned long long, or using the PRIu64 macro with type uint64_t.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711