[lug] OT: My own C/C++ mix Q

Scott A. Herod herod at interact-tv.com
Wed Apr 17 13:52:46 MDT 2002


"D. Stimits" wrote:

> Second, on sscanf() and sprintf(), a %lu can be used for an unsigned
> long format. I *think* %llu is good for the 64 bit unsigned long long,
> or at least the warnings go away (this is on g++ RH 7.1). Is %llu the
> correct format string for 64 bit unsigned longs (my references are too
> old to even know about long long)?

Yes on this one.  However, I don't know that you can guarantee that 
long long is defined and is 64 bit.  Check in limits.h which for example
in 2.96 has:

/* Minimum and maximum values a `signed long long int' can hold.  */
#   define LLONG_MAX    9223372036854775807LL
#   define LLONG_MIN    (-LLONG_MAX - 1LL)
 
/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0.) 
*/
#   define ULLONG_MAX   18446744073709551615ULL



More information about the LUG mailing list