473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 17908
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joerg Schwerdtfeger | last post by:
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,...
31
by: muralipmanohar | last post by:
Hello all , I need a help on this code kindly help me out for the below code I worked on the Turboc the result I was expecting was different from what has been printed I have indicated the line...
5
by: diadia | last post by:
#include <sys/types.h> #include <sys/stat.h> #include "ctype.h" #include <stdio.h> int estimateLen(struct stat buf, FILE *fp) { size_t _size = buf.st_size / 4;
25
by: Joakim Hove | last post by:
Hello, I have code which makses use of variables of type size_t. The code is originally developed on a 32 bit machine, but now it is run on both a 32 bit and a 64 bit machine. In the code...
3
by: nandh_dp | last post by:
When the below program is compiled and executed, #include <stdio.h> #define MASK 0xFFFFFFULL main() { unsigned long long a; unsigned long b, c;
2
by: Jude | last post by:
here is the source code: #include<stdio.h> int main() { float f; scanf("%d%f",&f); printf("The float is %10.5f\n",f); return 0; } when I input 12345.11111,the output is 12345.11133.
43
by: Joe Smith | last post by:
#include <stdio.h> int main(void) { unsigned long gcd(unsigned long m, unsigned long n); unsigned long m; unsigned long n; unsigned long t; m = 2520; n = 154;
19
by: v4vijayakumar | last post by:
why the following statement dumps the core(Segmentation fault)? printf("%s\n", __FILE__);
3
by: pranab.salian | last post by:
I need to compile some newer code in Borland TC 3.0. Here's the snippet.. /* CODE */ /* // --------------------------------------------------------------- // Shift register implementation:...
6
by: ray.webster | last post by:
Should the following work *if* I have a c99 compiler please? #include <stdio.h> int main(void) { size_t t = 42; # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.