jacob navia <ja***@jacob.remcomp.fr> writes:
silangdon wrote: Hi, I've need a function to print a long long to the console and
needs to
run under Win32 and some unknown variant of *Nix (a client's
unspecified server)
in Win32 I've got _int64 iVal
sprintf(cTemp, "Wrong length %I64d\n", iVal);
The control code (and the _int 64 type) aren't standard C I'd rather
use a runtime function that write m own...
Ta.
In standard C you can write:
long long iVal;
sprintf(cTemp,"Wrong length %lld\n",iVal);
long long is a standard C99 type, and its format is %lld
Yes, but it's entirely possible that the OP needs to deal with one or
more implementations that don't support long long and/or the "%lld"
format. (I've seen systems that have one but not the other.)
C99 is the official standard, but pretending it's universal in the
real world doesn't make it so, and doesn't help people who need to
deal with pre-C99 implementations.
Certainly you should use long long and "%lld" on systems that support
them (and even many pre-C99 implementations do so), but there's still
often a need to use non-standard extensions to C90 to achieve the same
result.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.