473,386 Members | 1,883 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.

in c language how can I use a long long integer? also printf and scanf?

1
in c language how can i use long long integer ? also printf scanf ? pls ans my ques
Jan 21 '13 #1
2 2270
weaknessforcats
9,208 Expert Mod 8TB
You would need to research a little.

First define a long long integer and a long integer.

Second, do a sizeof on each of these variables.

Third, if the sizeof each variable is the same you can use
%ld in printf and scanf. If the long long int is larger than the long int, you may need to write your own printf and scanf equivalents. A litte testing here will resolve this.
Jan 21 '13 #2
Banfa
9,065 Expert Mod 8TB
long long int was added to C99 and was supported as an extension by some C89/90 compilers well before C99 was introduced.

For compilers supporting long long int:

You can specify a long long int constant by appending LL to the end of your constant 1LL, similary you can use ULL for an unsigned long long int constant.

For printf and scanf you can use the modifier ll in the same way you would have used the l modifier for longs

Expand|Select|Wrap|Line Numbers
  1. long long int value = 5LL;
  2.  
  3. printf("%lld\n", value);
  4.  
Generally if a C89/90 compiler supports long long as an extension then it will have support for constants of the type and support in scanf/printf too. However that support may not conform exactly to the C99 standard, i.e. it may use something other than ll as a modifier in printf strings.

You need to check the documentation of the platform/compiler to see what it supports.
Jan 21 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: Richard A. Huebner | last post by:
Is the unsigned long long primitive data type supported in ANSI standard C? I've tried using it a couple of times in standard C, but to no avail. I'm using both MS VIsual C++ 6, as well as the...
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,...
5
by: dijaster | last post by:
Recently I have had the need to run loops of at least 10^10 steps. Since 32 bit integers apparently can only store values up to about 2*10^9, I have tried to use the "long long" data type. However,...
12
by: __frank__ | last post by:
Which format I have to use in scanf, to format a long long int (64bits int __int64 in MS VC++). Thanks in advance
36
by: Digital Puer | last post by:
Hi, suppose I have an unsigned long long. I would like to extract the front 'n' bits of this value and convert them into an integer. For example, if I extract the first 3 bits, I would get an int...
9
by: luke | last post by:
Hi everybody, please, can someone explain me this behaviour. I have the following piece of code: long long ll; unsigned int i = 2; ll = -1 * i; printf("%lld\n", ll);
7
by: wenmang | last post by:
what is format for sprintf to convert long long integer (64 bits) to string?
12
by: wenmang | last post by:
Hi, I am using following Oracle Proc-C compiler: Pro*C/C++: Release 8.1.7.0.0 - Production on Thu Jun 15 15:57:32 2006 (c) Copyright 2000 Oracle Corporation. All rights reserved. I like to...
21
by: Charles Sullivan | last post by:
I maintain/enhance some inherited FOSS software in C which has compiler options for quite a few different Unix-like operating systems, many of which I've never even heard of. It would be...
21
by: Bart C | last post by:
I've always had a problem knowing exactly how wide my integer variables were in C, and the little program below has increased my confusion. Run on 3 compilers on the same cpu (32-bit pentium),...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.