472,783 Members | 1,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 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 7349
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;
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.