From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: linux c programming mailing list <linux-c-programming@vger.kernel.org>
Subject: Re: invalid lvalue
Date: Sat, 15 Feb 2003 16:40:58 +0100 [thread overview]
Message-ID: <20030215154058.GC351@lug-owl.de> (raw)
In-Reply-To: <Pine.LNX.4.33.0302152054580.24802-100000@soochak.ncst.ernet.in>
[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]
On Sat, 2003-02-15 20:57:35 +0530, Mohammed Khalid Ansari <khalid@ncst.ernet.in>
wrote in message <Pine.LNX.4.33.0302152054580.24802-100000@soochak.ncst.ernet.in>:
>
> I tried to compile the following program...
>
> int main()
> {
> int a;
> a = 2;
> # printf ("%d\n", a++++);
> return 0;
> }
> "invalid lvalue in increment" for the line indicated by #. Why it so, a
> has been defined as an int variable!
Well, the compiler seemed to read this as (a++)++ . The braces are
evaluated (this results in a _number), and then you try to increment
this number. But this doesn't work, because "++" is ment for variables,
not for numbers.
Use 'printf ("%d\n", a += 2);' instead (if it was your intend to add two
to a).
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur
fuer einen Freien Staat voll Freier Bürger" | im Internet!
Shell Script APT-Proxy: http://lug-owl.de/~jbglaw/software/ap2/
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2003-02-15 15:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-15 15:27 invalid lvalue Mohammed Khalid Ansari
2003-02-15 15:40 ` Jan-Benedict Glaw [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030215154058.GC351@lug-owl.de \
--to=jbglaw@lug-owl.de \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).