-4

In C language, how to use printf to output such a format, for example,

  1. unsigned long int
  2. unsigned long long int
  3. unsigned int
  4. long long int
  5. long int

How to calculate the bytes occupied by them?

I mainly want to know the output format of unsigned long int, but it seems that there is no introduction in the document, only some very similar. For example, unsigned long or unsigned long long. This format is the type of uint64_t

Gerrie
  • 736
  • 3
  • 18

1 Answers1

1

sizeof gives you the size of any variable you wish.

For the list of every output format of printf, check the manual.

Román
  • 136
  • 1
  • 9
  • I think he means the number of bytes in the formatted output, not the original variable. – Barmar Oct 12 '20 at 14:32
  • I still don't know the output format of unsigned long int, and its output is not described in this document. Does the document mean to be converted to other formats for output? I only saw unsigned long and unsigned long long, but not unsigned long int. Is the correct format of unsigned long int %lud? – Gerrie Oct 12 '20 at 14:36
  • 1
    In the manual, check the "Length modifier". I'm not 100% sure of the correct format but I would say it is ````%lu````. I tried it in local and seemed to work. – Román Oct 12 '20 at 14:50
  • 1
    Thank you. It works – Gerrie Oct 12 '20 at 14:55