Using _int64 datatype with iostream ( cin, cout )

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
soyoja
Experienced poster
Posts: 106
Joined: Sun Feb 17, 2002 2:00 am
Location: Seoul, South Korea
Contact:

Using _int64 datatype with iostream ( cin, cout )

Post by soyoja »

When I use _int64 in C language, I used below.

[c]
_int64 x;
printf("%I64d", x );
[/c]

But I want to use _int64 with iostream. When I wrote this code,

[cpp]
cout << x;
[/cpp]

Visual C compiler say " Error : 'operator <<' is ambiguous ".

What is wrong? How can I use cin or cout with _int64 data type?

I read MSDN and other references, But I can't find the solution.

Please help me.
[/cpp]
Viktoras Jucikas
New poster
Posts: 22
Joined: Sun Oct 20, 2002 6:41 pm
Location: Lithuania
Contact:

Post by Viktoras Jucikas »

Looks like your iostream library does not support non-ansi types. Solution would be to use printf() or write your own operator<<(ostream, __int64) (based on printf()).
soyoja
Experienced poster
Posts: 106
Joined: Sun Feb 17, 2002 2:00 am
Location: Seoul, South Korea
Contact:

Post by soyoja »

I have a question...

Does Online Judge system support non - ansi type?

Could OJ system accept " cin << x; " ? // x is long long type
Viktoras Jucikas
New poster
Posts: 22
Joined: Sun Oct 20, 2002 6:41 pm
Location: Lithuania
Contact:

Post by Viktoras Jucikas »

If I remember correctly, long long is not ISO c++ type (though it is already present in C99 standard). However, many compilers (g++ being one of them) support long long (as well as libraries like iostream do). I'm sure that judge is not using --strict compiler option (which enforces strict ISO compatibility) as some code I have succesfully submited contained operations with long long types (though I have used printf/scanf family for IO):wink:
Post Reply

Return to “C++”