473,385 Members | 1,518 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,385 software developers and data experts.

using long long

Hi,
Why is the code not getting compiled ? I am using SuSe linux. Is
it becuase of that ?

#include<stdio.h>
int main()
{
long long i;
i = LL 9876543219;
printf("%ld\n", i);
}
Error message is

longLong.cpp:6: error: integer constant is too large for "long" type
longLong.cpp:6: error: `LL' undeclared (first use this function)
longLong.cpp:6: error: (Each undeclared identifier is reported only
once for
each function it appears in.)
longLong.cpp:6: error: syntax error before numeric constant

Thanks in advance
Kiran.

Nov 6 '06 #1
17 2318
jithoosin wrote:
Hi,
Why is the code not getting compiled ? I am using SuSe linux. Is
it becuase of that ?

#include<stdio.h>
int main()
{
long long i;
i = LL 9876543219;

The 'LL' goes *after* the number:

i = 9876543219LL;
printf("%ld\n", i);
}

These error messages (and the ".cpp" suffix of your files) suggest to me
that you're compiling this code as C++, not C. Be aware that they are
two different languages, and have different rules (for instance, 'long
long' is not yet a standard type in C++, which is why C++ warns you
about values that are too large for 'long').
Error message is

longLong.cpp:6: error: integer constant is too large for "long" type
longLong.cpp:6: error: `LL' undeclared (first use this function)
longLong.cpp:6: error: (Each undeclared identifier is reported only
once for
each function it appears in.)
longLong.cpp:6: error: syntax error before numeric constant

Thanks in advance
Kiran.

--
Clark S. Cox III
cl*******@gmail.com
Nov 6 '06 #2
jithoosin said:
Hi,
Why is the code not getting compiled ? I am using SuSe linux. Is
it becuase of that ?
No, it's because you used LL 9876543219 instead of 9876543219LL in your
assignment to i. Your code also has other problems - particularly the
incorrect format specifier for long long int in your printf call.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #3
Clark S. Cox III said:
These error messages (and the ".cpp" suffix of your files) suggest to me
that you're compiling this code as C++, not C.
Ah, nice spot (which I overlooked completely). He'll want to change that to
a .c suffix, methinks.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #4
Hi,
Thanks, that worked. But i still wants i have one more
doubt.What should be the format specifier in printf ?

Thanks
Kiran.

Richard Heathfield wrote:
jithoosin said:
Hi,
Why is the code not getting compiled ? I am using SuSe linux. Is
it becuase of that ?

No, it's because you used LL 9876543219 instead of 9876543219LL in your
assignment to i. Your code also has other problems - particularly the
incorrect format specifier for long long int in your printf call.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #5
Richard Heathfield wrote:
Clark S. Cox III said:
>These error messages (and the ".cpp" suffix of your files) suggest
to me that you're compiling this code as C++, not C.

Ah, nice spot (which I overlooked completely). He'll want to change
that to a .c suffix, methinks.
And ensure that he is using a C99 compiler.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

Nov 6 '06 #6
CBFalconer said:
Richard Heathfield wrote:
>Clark S. Cox III said:
>>These error messages (and the ".cpp" suffix of your files) suggest
to me that you're compiling this code as C++, not C.

Ah, nice spot (which I overlooked completely). He'll want to change
that to a .c suffix, methinks.

And ensure that he is using a C99 compiler.
That could be tricky. Or expensive. One of those.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #7
jithoosin said:
Hi,
Thanks, that worked. But i still wants i have one more
doubt.What should be the format specifier in printf ?
The format specifier for what? printf supports many format specifiers.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #8
2006-11-06 <bu********************@bt.com>,
Richard Heathfield wrote:
jithoosin said:
>Hi,
Thanks, that worked. But i still wants i have one more
doubt.What should be the format specifier in printf ?

The format specifier for what? printf supports many format specifiers.
In this case, the one he's looking for is %lld - which no-one pointed
out he should have been using instead of %ld in the original code.
Nov 6 '06 #9
Jordan Abel said:
2006-11-06 <bu********************@bt.com>,
Richard Heathfield wrote:
>jithoosin said:
>>Hi,
Thanks, that worked. But i still wants i have one more
doubt.What should be the format specifier in printf ?

The format specifier for what? printf supports many format specifiers.

In this case, the one he's looking for is %lld - which no-one pointed
out he should have been using instead of %ld in the original code.
Ah, thanks for the reminder. He didn't include sufficient context above his
question for me to recall the thread. Now that you remind me, however, I am
also reminded that I did in fact point out to him that he was using the
wrong format specifier.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #10
2006-11-06 <oK******************************@bt.com>,
Richard Heathfield wrote:
Jordan Abel said:
>2006-11-06 <bu********************@bt.com>,
Richard Heathfield wrote:
>>jithoosin said:

Hi,
Thanks, that worked. But i still wants i have one more
doubt.What should be the format specifier in printf ?

The format specifier for what? printf supports many format specifiers.

In this case, the one he's looking for is %lld - which no-one pointed
out he should have been using instead of %ld in the original code.

Ah, thanks for the reminder. He didn't include sufficient context above his
question for me to recall the thread. Now that you remind me, however, I am
also reminded that I did in fact point out to him that he was using the
wrong format specifier.
Yes, which he quoted when he asked which one he should be using (which
you didn't say)

Probably it was the top-posting that threw you off.
Nov 6 '06 #11
Jordan Abel said:

<snip>
Probably it was the top-posting that threw you off.
Ah, that would be it. I wonder why he did that. Oh well - he'll learn, I
guess.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #12
Hi all,
Thanks a lot for all these help. I more doubt. What is top
posting and am i the one who did that ?

tHANKS
kIRAN

Richard Heathfield wrote:
Jordan Abel said:

<snip>
Probably it was the top-posting that threw you off.

Ah, that would be it. I wonder why he did that. Oh well - he'll learn, I
guess.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #13
2006-11-06 <11**********************@m73g2000cwd.googlegroups .com>,
jithoosin wrote:
What is top posting and am i the one who did that ?
Top-posting is when you place your original text at the top of the
message above the text you're responding to. You should be replying at
the bottom.
Nov 6 '06 #14
jithoosin wrote:
>
Thanks a lot for all these help. I more doubt. What is top
posting and am i the one who did that ?
You did it again. Your answer belongs after, or possibly
intermixed with, the snipped material you quote. The snipping
removes anything not germane to your reply. See the following
links:

--
Some informative links:
<news:news.announce.newusers
<http://www.geocities.com/nnqweb/>
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/>

Nov 6 '06 #15
Richard Heathfield wrote:
CBFalconer said:
And ensure that he is using a C99 compiler.

That could be tricky. Or expensive. One of those.
Indeed. It could take minutes to find a free compiler that supports
long long as per
C99. And probably a further 20 to download and install it. Oh the
humanity.

--
Peter

Nov 6 '06 #16
Peter Nilsson said:
Richard Heathfield wrote:
>CBFalconer said:
And ensure that he is using a C99 compiler.

That could be tricky. Or expensive. One of those.

Indeed. It could take minutes to find a free compiler that supports
long long as per C99.
Oh, if you *only* want long long support, that's no big deal - provided
you're prepared to forego conforming mode. But an actual conforming C99
compiler, available for free? I Don't Think So (tm).

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 6 '06 #17
Richard Heathfield wrote:
Peter Nilsson said:

>>Richard Heathfield wrote:
>>>CBFalconer said:

And ensure that he is using a C99 compiler.

That could be tricky. Or expensive. One of those.

Indeed. It could take minutes to find a free compiler that supports
long long as per C99.


Oh, if you *only* want long long support, that's no big deal - provided
you're prepared to forego conforming mode. But an actual conforming C99
compiler, available for free? I Don't Think So (tm).
Sun's compiler is close and getting closer with each release. Not there
yet, but it will be.

--
Ian Collins.
Nov 7 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chuck Rittersdorf | last post by:
Hi There I am having a problem using the win32 API from VB6. I am trying to send a command string to a printer(zebra TLP 2742) on LPT1 using the folowing API functions CreateFile and...
9
by: none | last post by:
Hello all, I wrote a shell program a few years ago in VB6 that needs to be modified. The problem I have is this: The SysAdmin uses this shell in place of Explorer, so there is no taskbar. When...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
2
by: praveenkojha | last post by:
Hi, I am novice in C++ and am more of a C# guy. I have a third party C++ code which I want to create and use as a managed assembly. I have created a .NET win32 application and have copied this...
3
by: Rob | last post by:
Hi all, I am having trouble converting the code below (found on http://vbnet.mvps.org/index.html?code/core/sendmessage.htm) into a format that will work using vb .NET. Can anyone have a look...
9
by: Ron | last post by:
Hello, Is it required to use Imports System.Runtime.InteropServices to run C++ API code? I ask because I thought I read somewhere that this was required. If it is not required would it...
1
by: handokowidjaja | last post by:
Hi All, Several weeks ago i started a topic with the same subject, however the solutions provided was for using MS Outlook (fullblown version). I finally found something that works directly with...
2
by: tristanlbailey | last post by:
I been scouring the Internet for an answer to my problem, and a couple of times thought I had almost found the answer, but still to no avail. I'm tying to use the Rich Edit class (riched20.dll),...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.