* invalid lvalue
@ 2003-02-15 15:27 Mohammed Khalid Ansari
2003-02-15 15:40 ` Jan-Benedict Glaw
0 siblings, 1 reply; 2+ messages in thread
From: Mohammed Khalid Ansari @ 2003-02-15 15:27 UTC (permalink / raw)
To: linux c programming mailing list
I tried to compile the following program...
int main()
{
int a;
a = 2;
# printf ("%d\n", a++++);
return 0;
}
but it gave the following error.
"invalid lvalue in increment" for the line indicated by #. Why it so, a
has been defined as an int variable!
--
**************************************************************************
Mohammed Khalid Ansari Tel (res) : 0091-022-3051360
Assistant Manager II (off) : 0091-022-2024641
National Centre for Software Technology Fax : 0091-022-2049573
8th flr,Air India Build. Nariman Point, E-Mail : khalid@ncst.ernet.in
Mumbai 400021.
Homepage : http://soochak.ncst.ernet.in/~khalid
**************************************************************************
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: invalid lvalue
2003-02-15 15:27 invalid lvalue Mohammed Khalid Ansari
@ 2003-02-15 15:40 ` Jan-Benedict Glaw
0 siblings, 0 replies; 2+ messages in thread
From: Jan-Benedict Glaw @ 2003-02-15 15:40 UTC (permalink / raw)
To: linux c programming mailing list
[-- 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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-02-15 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-15 15:27 invalid lvalue Mohammed Khalid Ansari
2003-02-15 15:40 ` Jan-Benedict Glaw
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).