F
__frank__
Which format I have to use in scanf,
to format a long long int (64bits int
__int64 in MS VC++).
Thanks in advance
to format a long long int (64bits int
__int64 in MS VC++).
Thanks in advance
__frank__ said:Which format I have to use in scanf,
to format a long long int (64bits int
__int64 in MS VC++).
__frank__ said:Which format I have to use in scanf,
to format a long long int (64bits int
__int64 in MS VC++).
Thanks in advance
^Keith said:"%lld", if your library supports it. It's required by C99, but of
course there was long long type in C90.
Michael Mair said:^
no
"%lld" or "%lli".
Note: The long long integer types are in the language since C99;
AFAIK, MS VC will not fully support C99 even in their 2005 Studio.
At least in VC++6, the semantics of the 64 bit types were partially
broken.
If the above format does not work, you have a 64 bit type as an
implementation specific extension; the format should be specified
in the online help. Otherwise, you may have to ask in a newsgroup
or forum where your implementation is topical.
BTW: If you try to keep your code conforming, you can #define
the appropriate integer conversion format strings and work with
them like that:
#if (defined __STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define MY_SLLFORMAT "%lld"
# define MY_ULLFORMAT "%llu"
#elif ...... /* ask for your implementation */
..../* Define your implementation specific MY_SLLFORMAT etc here */
#else
# error Cannot define an appropriate 64 bit integer format
#end
....
printf("Tit (" MY_SLLFORMAT ") for tat\n", mylonglongvar);
Cheers
Michael
In MS VC++, '__int64' read by this wayWhich format I have to use in scanf,
to format a long long int (64bits int
__int64 in MS VC++).
Thanks in advance
kaikai said:__frank__ 写é“:
In MS VC++, '__int64' read by this way
__int64 i;
scanf("%I64d", &i);
Jordan said:Usually when defining a macro for a format specifier you don't want
to include the % sign, so as to allow the user to include field
widths and so on
for example
#define PRIdLLONG "lld"
#define PRIuLLONG "llu"
printf("Here's an example with a field width: %10"PRIdLLONG"\n", var);
Keith said:And *only* (as far as I know) in MS VC++. "%I64d" is non-standard and
non-portable. Writing non-portable code is sometimes necessary, of
course.
Usually when defining a macro for a format specifier you don't want
to include the % sign, so as to allow the user to include field
widths and so on
And *only* (as far as I know) in MS VC++. "%I64d" is non-standard and
non-portable. Writing non-portable code is sometimes necessary, of
course.
It is also supported by WATCOM C/C++, Borland C, and the Alpha
compiler. This, presumably, is why C99 included stdint.h, and
inttypes.h which includes abstractions for all these things.
The only problem, of course, is that nobody seriously supports C99.
Greg said:Comeau and Dinkumware do. The industry is another story.
Comeau and Dinkumware also support MSisms well too.
IBM does too for its z/OS mainframe C
...
| ISO/IEC 9899:1999 <-----<< isn't this C99?
Usually when defining a macro for a format specifier you don't want
to include the % sign, so as to allow the user to include field
widths and so on
for example
#define PRIdLLONG "lld"
#define PRIuLLONG "llu"
printf("Here's an example with a field width: %10"PRIdLLONG"\n", var);
[i don't know if the entire PRI*/SCN* set of identifiers are
reserved if inttypes.h is included - however if his system has
inttypes.h he should probably be using the types defined therein
instead]
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.