inttypes.h

B

Bill Cunningham

I am not really to my knowledge ever going to use these but there are
macros from inttypes.h called PRIxxx and SCNxxx what are thet for. They are
specific to the fprintf and printf family of functions. I understand the use
of int32_t and int64_t from stdint.h included in inttypes but how are these
macros used?

Bill
 
S

Siri Cruise

Bill Cunningham said:
I am not really to my knowledge ever going to use these but there are
macros from inttypes.h called PRIxxx and SCNxxx what are thet for. They are
specific to the fprintf and printf family of functions. I understand the use
of int32_t and int64_t from stdint.h included in inttypes but how are these
macros used?


printf("this is int64_t: %" PRId64 "\n", (int64_t)42);
 
B

boon

Ok then PRI is for printf and SCN for scanf?

Yes:

/*
* <inttypes.h> -- Standard C header, defined in ISO/IEC 9899:1999
* (aka "C99"), section 7.8. This defines format string conversion
* specifiers suitable for use within arguments to fprintf and fscanf
* and their ilk.
*/

In "C reference Manual, fifth edition" (Harbisson & Steele) par. 21.1.4:

The macros PRIcKN and SCNcKN are format control strings for the
'printf' and 'scanf' families of functions etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top