473,395 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

stdint.h vs. stdio.h

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)..

Jun 8 '06 #1
4 3561
copx wrote:
How can you use printf/scanf/etc. while using stdint.h types?
Using the macros defined in <inttypes.h>
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.

Jun 8 '06 #2
copx <no@spam.ru> wrote:
# 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)..
#
#
#

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Don't say anything. Especially you.
Jun 8 '06 #3
copx <no@spam.ru> wrote:
# 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);

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Don't say anything. Especially you.
Jun 8 '06 #4
copx schrieb:
How can you use printf/scanf/etc. while using stdint.h types?

[snip]

Thanks!

Jun 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Scott David Daniels | last post by:
I am trying to figure out how to get 2.4a2 to build a python extension. GCC 2.2.95 does not have a stdint.h, but 3.2.3 does. These two are the only gcc versions I have on my box. Does anyone...
6
by: J. Campbell | last post by:
I'm wondering if there are any compelling reasons NOT to use the types defined in stdint.h in c-programms? Please refer to this thread:...
8
by: phil-news-nospam | last post by:
I have some code where I am using certain literal values cast to stdint types like uint32_t, uint64_t, etc. In gcc versions below 3.3 it's working OK. Here's an example: (uint64_t)...
1
by: shaun roe | last post by:
Is there a c++ version of the old stdint.h header? I naively tried <cstdint>, and looking quickly on the web I find only discussion but no real answer... cheers shaun
4
by: copx | last post by:
I wonder how portable the exact width types defined by stdint.h are. I guess target platforms are not required to actually have all those types, right? What happens in that case?
11
by: santosh | last post by:
Hello all, Conversion macros along the name of INT8_C, INT16_C etc, are defined in stdint.h to convert their argument into suitable representations for their corresponding types, i.e. int8_t,...
10
by: Mikail Dellovich | last post by:
stdint.h exists on my Solaris 10(sparc) system but not on my Solaris 9(sparc) system. How do I rectify this situation? Thanks
130
by: euler70 | last post by:
char and unsigned char have specific purposes: char is useful for representing characters of the basic execution character set and unsigned char is useful for representing the values of individual...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.