stdint.h vs. stdio.h

C

copx

How can you use printf/scanf/etc. while using stdint.h types?

I mean if you use int_least64_t for example; how do you know the proper
format identifier?
On a 64bit platform int_least64_t might be defined as "int" (%d) while
on a 32bit platform it might be a "long int" (%ld)..
 
G

Guest

copx said:
How can you use printf/scanf/etc. while using stdint.h types?

Using the macros defined in said:
I mean if you use int_least64_t for example; how do you know the proper
format identifier?
On a 64bit platform int_least64_t might be defined as "int" (%d) while
on a 32bit platform it might be a "long int" (%ld)..

It's extremely ugly, but:
printf("%" PRIdLEAST64 "\n", (int_least64_t) 0);

It's up to the implementation to define the macro as "d", "ld", or
whatever is appropriate for that specific platform.
 
S

SM Ryan

# How can you use printf/scanf/etc. while using stdint.h types?
#
# I mean if you use int_least64_t for example; how do you know the proper
# format identifier?
# On a 64bit platform int_least64_t might be defined as "int" (%d) while
# on a 32bit platform it might be a "long int" (%ld)..
#
#
#
 
S

SM Ryan

# How can you use printf/scanf/etc. while using stdint.h types?

You can cast to a known type.
int_ZZ_t zork;
printf("%lld\n",(long long)zork);
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top