long long with printf

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

Moderator: Board moderators

Post Reply
PMNOX
New poster
Posts: 49
Joined: Wed Feb 13, 2002 2:00 am
Location: Poland
Contact:

long long with printf

Post by PMNOX »

I tried to use: printf("%lld,r); and printf("%I64d,r); to print long longer but it doesn't work on acm :(

int main()
{
long long r = 12345678901234LL;

printf("%lld,r);

}
Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per »

Well, you do need to terminate the quote...

The %lld flag for scanf doesn't work at all (it just produces garbage) in the version of gcc+cygwin I have, but otherwise I've never had any problems with %lld.
anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post by anupam »

I never faced any problem too.
"Everything should be made simple, but not always simpler"
UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

Post by UFP2161 »

For Cygwin, I had to use %L for scanf and %lld for printf. Strange, huh? But when I submit, I always have to change the %L back to %lld.
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

So your Cygwin installation is somehow broken. On my box %lld works fine with both printf and scanf, on g++ 2.95 and 3.31.
Subeen
Experienced poster
Posts: 127
Joined: Tue Nov 06, 2001 2:00 am
Location: Bangladesh
Contact:

Post by Subeen »

I also use %lld, but %lli should also work for long long integer, and %llu is for unsigned long long integer.
Post Reply

Return to “C++”