plz c d following code
#include<stdio. h>
void main()
{
int x=4,y=1;
y=x++++; //gives error message lvalue required
y=x++ + ++y;//no errors
y=x+++++y ;//lvalue required
y=(++x)++; //no errors
}
explanation needed for the all four statements nd a bit bout lvalues.
program tested on turbo 4.5 32 bit compiler. 14 9734
Akhil wrote: plz c d following code
Syntax error: non-word "plz".
Syntax error: unexpected initial "c".
Syntax error: unexpected initial "d".
Syntax error: imperative must end with "." or "!".
Warning: April is the cruelest month.
#include<stdio. h> void main()
non-int `main`s produce undefined behaviour.
{ int x=4,y=1;
y=x++++; //gives error message lvalue required
An "lvalue" is (roughly) an addressable object, a variable.
The left operand of ++ must be a lvalue. The result of ++
is a number. Numbers are not lvalues. QED.
program tested on turbo 4.5 32 bit compiler.
If it were a program, it would have compiled.
--
Chris "try, or try not -- there is no do" Dollin
thnx for d reply but i still hav a problem ....
if we exeucte the statement y=(++x)++; then thr is no error ++x will
again b a number nd left operand of ++ shud b a lvalue so y does it
work in this case.
Akhil wrote: thnx for d reply but i still hav a problem ....
Yes, you're still writing in gobbledegook. Please use English words
and English grammar.
if we exeucte the statement y=(++x)++; then thr is no error
Yes, there is - "invalid lvalue in increment" is how my local gcc reported
it.
++x will again b a number nd left operand of ++ shud b a lvalue so y does it work in this case.
Broken compiler - /if/ it really did work.
--
Chris "try, or try not -- there is no do" Dollin
Akhil wrote: plz c d following code
Gobble-de-gook is not understandable. #include<stdio. h> void main()
main returns int. All bets are off.
{ int x=4,y=1;
y=x++++; //gives error message lvalue required
Syntax errors normally do that.
.... snip ... program tested on turbo 4.5 32 bit compiler.
No non-compilable program is tested.
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/>
Akhil wrote: plz c d following code
#include<stdio. h> void main() { int x=4,y=1;
y=x++++; //gives error message lvalue required
You can't modify the result of x++, so it can't be an lvalue (something
that appears on the left hand side of an expression).
--
Ian Collins.
Ian Collins wrote: Akhil wrote:
plz c d following code
#include<stdio. h> void main() { int x=4,y=1;
y=x++++; //gives error message lvalue required You can't modify the result of x++, so it can't be an lvalue (something that appears on the left hand side of an expression).
Sorry, that came out wrong, I should have said you can't modify the
expression x++.
--
Ian Collins.
On 2006-02-08, Akhil <ak************ *@gmail.com> wrote: plz c d following code
#include<stdio. h> void main() { int x=4,y=1;
y=x++++; //gives error message lvalue required
x++ returns a value, which you are then trying to increment
y=x++ + ++y;//no errors
Except, of course, the undefined behavior
y=x+++++y ;//lvalue required
this parses as x++ ++ +y
y=(++x)++; //no errors
It _should_ be the same error as x++++ - i can't imagine why it's not.
Have you actually tried this, or did your teacher just _say_ there are
no errors?
}
explanation needed for the all four statements nd a bit bout lvalues.
lvalues are, basically, expressions that it is legal to assign to /
modify / increment - say, the name of a variable.
program tested on turbo 4.5 32 bit compiler.
On 2006-02-08, Akhil <ak************ *@gmail.com> wrote: thnx for d reply but i still hav a problem ....
if we exeucte the statement y=(++x)++; then thr is no error ++x will again b a number nd left operand of ++ shud b a lvalue so y does it work in this case.
Your compiler failed to provide a required diagnostic, and is thus not a
conforming ANSI C implementation.
Jordan Abel wrote: On 2006-02-08, Akhil <ak************ *@gmail.com> wrote:
y=(++x)++; //no errors
It _should_ be the same error as x++++ - i can't imagine why it's not. Have you actually tried this, or did your teacher just _say_ there are no errors?
It certainly produces the same `lvalue` error on GCC 3.4.2
(mingw-special) when compiled with paranoid options. program tested on turbo 4.5 32 bit compiler.
Don't have this to test OP's results, but I have a strogn suspicion
that OP did not in fact try to compile this. If it does really compile
on TC 4.5, I'd complain to the vendor, but that won't work, as it's
discontinued.
--
BR, Vladimir This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hongzheng Wang |
last post by:
In K&R, they said:
An object is a named region of storage; an lvalue is an expression
refer to an object.
How about these concept in C++?
`The C++ Programming Language' has a similar explanation, however, it
may be too brief.
Can anyone give me a more detailed explanation? Or give some referrences
|
by: Stub |
last post by:
The following code gives error C2105: '++' needs l-value.
char buf;
buf++ = 'A';//buf++ isn't a lvalue
Why buf++ isn't a lvalue? Is this according to C Standard or is there
some reason for this?
If buf++ isn't a lvalue, then why the following code works?
|
by: Michael Baehr |
last post by:
I recently upgraded my Arch Linux system to GCC 3.4, and found out that a
previously accepted behavior (cast-as-lvalue) is now marked as deprecated,
and will cease to function in GCC 3.5. This has caused several builds to
break, most notably elfutils.
Presumably this behavior is not part of the C standard and it is thus
being excised like many other nonstandard GCC extensions. Regardless, my
question is not about the specifics or...
|
by: tkrogc |
last post by:
I compiled the source below using the comeau compiler
http://www.comeaucomputing.com/tryitout/
Why does the f funtion compile while the g function produces an lvalue
error ?
(I thought the two functions were identical except for a harmless
syntax difference)
struct A
{
void f(){}
|
by: Kavya |
last post by:
Can someone give and explain in simple terms a definition of lvalue?
Also what are these modifiable and non-modifiable lvalues?
I always thought that, if we can assign to anything then that anything
is lvalue and if cannot assign to anything then that anything is not
lvalue.
| |
by: lovecreatesbea... |
last post by:
K&R2, both sec A7.3.4 Postfix Incrementation and secA.7.4.1 Prefix
Incrementation Operators say that "The result is not an lvalue". Is
this correct? I don't see an errata on these points. If below the p++
or ++p is not an lvalue, then *p++ or *++p is a syntax error.
When it talks about Unary Operators, why doesn't the secA7.4 collect
both the prefix and postfix incrementation operators together?
int main(void)
{
|
by: subramanian100in |
last post by:
Consider the following:
int x;
int y;
int z;
(x+y) = z;
For this statement, I get the following error with g++ compiler:
error: non-lvalue in assignment
Suppose I have a class Test and x, y, z are objects of type Test.
|
by: Rahul |
last post by:
Hi Everyone,
I have the following piece of code, and i expected an error, however
i don't get an error,
int main()
{
int aa=0,b=0;
1>0?aa:b = 10;
printf("value %d %d\n",aa,b);
|
by: markryde |
last post by:
Hello,
Followed here is a simplified code example of something which I
try to implement; in essence , I want to assign a value to a return
value of a method is C. I know, of course, that in this example I
can
get this by newskb->iph = iphdr (this also appears in a commented
line in the example below) ; but I want to achieve the same where
the left side is : ip_hdr(newskb). Alas, if I try this , I get
a compilation error about line 25....
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |