469,612 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

printf / sscanf unsigned long long int variables

Hi everyone,

I want to input & output an unsigned long long int variable, but
printf/sscanf seems to interpret the least significant 32 bits only.

I assume this is a bloody newbie-question, but reading the clc-faq and
googleing for this issue, I only found out that this might be a known
problem - but how can I fix it? Are there any workarounds, e.g. other
io-routines who can handle ull-ints?

Thanks in advance,
Joerg

Nov 14 '05 #1
3 7105
Joerg Schwerdtfeger wrote:
Hi everyone,

I want to input & output an unsigned long long int variable, but
printf/sscanf seems to interpret the least significant 32 bits only.


use the %llu format specifier for unsigned long longs

--
John Tsiombikas (Nuclear / the Lab)
nu*****@siggraph.org
http://thelab.demoscene.gr/nuclear/
Nov 14 '05 #2

"Joerg Schwerdtfeger" <sc*******@gmx.de> wrote in message news:c4*************@news.t-online.com...
Hi everyone,

I want to input & output an unsigned long long int variable, but
printf/sscanf seems to interpret the least significant 32 bits only.
Does your compiler support ULLs?

I assume this is a bloody newbie-question, but reading the clc-faq and
googleing for this issue, I only found out that this might be a known
problem - but how can I fix it? Are there any workarounds, e.g. other
io-routines who can handle ull-ints?

Thanks in advance,
Joerg


F:\Vijay\C> type ull.c
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int
main ( void )
{
unsigned long long int ull;
printf ( "ULLONG_MAX: %llu\n", ULLONG_MAX );
printf ( "Enter an ull value: " );
scanf ( "%llu", &ull );
printf ( "\nThe ull value is: " );
printf ( "%llu", ull );
return EXIT_SUCCESS;
}

F:\Vijay\C> gcc -std=c99 -Wall
F:\Vijay\C> a.exe
ULLONG_MAX: 18446744073709551615
Enter an ull value: 18446744073709551614
The ull value is: 18446744073709551614

Nov 14 '05 #3
Vijay Kumar R Zanvar wrote:
scanf ( "%llu", &ull );
printf ( "%llu", ull );


Damn! I used %ull instead of %llu. *embarrassed*

Thank you so much!
Nov 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Joerg Schwerdtfeger | last post: by
31 posts views Thread by muralipmanohar | last post: by
5 posts views Thread by diadia | last post: by
25 posts views Thread by Joakim Hove | last post: by
2 posts views Thread by Jude | last post: by
43 posts views Thread by Joe Smith | last post: by
3 posts views Thread by pranab.salian | last post: by
6 posts views Thread by ray.webster | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.