printf / sscanf unsigned long long int variables

  • Thread starter Joerg Schwerdtfeger
  • Start date

J

Joerg Schwerdtfeger

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
 
Ad

Advertisements

J

John Tsiombikas (Nuclear / the Lab)

Joerg said:
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
 
V

Vijay Kumar R Zanvar

Joerg Schwerdtfeger said:
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
 
Ad

Advertisements


Ask a Question

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.

Ask a Question

Top