473,473 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is the following an lvalue or rvalue

I have the folllowing

#include <stdio.h>

int main(void)
{
int x = 1, y = 2;
int *ip;

ip = &x;

y = *ip;

printf("The value is: %d\n", y);

return 0;
}
Would *ip in y = *ip be a lvalue or rvalue in this case? Here is my
main source of confusion. I thought that applying the indirection
operator to ip would yield a lvalue and thus something like *ip could
only appear on the left hand side. However,since *ip is on the right
hand side in this case, would *ip be a lvalue or rvalue?

Chad
Jul 14 '08 #1
2 1339
Chad wrote:
I have the folllowing

#include <stdio.h>

int main(void)
{
int x = 1, y = 2;
int *ip;

ip = &x;
y = *ip;

printf("The value is: %d\n", y);

return 0;
}
Would *ip in y = *ip be a lvalue or rvalue in this case? Here is my
main source of confusion. I thought that applying the indirection
operator to ip would yield a lvalue and thus something like *ip could
only appear on the left hand side. However,since *ip is on the right
hand side in this case, would *ip be a lvalue or rvalue?
It's a lvalue used in a rvalue context.

Jul 14 '08 #2
On Jul 14, 5:43*am, santosh <santosh....@gmail.comwrote:
Chad wrote:
I have the folllowing
#include <stdio.h>
int main(void)
{
* int x = 1, y = 2;
* int *ip;
* ip = &x;
* y = *ip;
* printf("The value is: %d\n", y);
* return 0;
}
Would *ip in y = *ip be a lvalue or rvalue in this case? Here is my
main source of confusion. I thought that applying the indirection
operator to ip would yield a lvalue and thus something like *ip could
only appear on the left hand side. However,since *ip is on the right
hand side in this case, would *ip be a lvalue or rvalue?

It's a lvalue used in a rvalue context.- Hide quoted text -

- Show quoted text -
Okay.
Jul 14 '08 #3

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

Similar topics

19
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...
4
by: Chris Mantoulidis | last post by:
Why is that? Why does ++x return lvalue and x++ return rvalue? for example, this will work ++x = 10; it will set x to 10... but this won't, cuz x++ is rvalue:
9
by: Steven T. Hatton | last post by:
This is from the draft of the previous version of the Standard: http://www.kuzbass.ru:8086/docs/isocpp/expr.html 2- A literal is a primary expression. Its type depends on its form...
24
by: Romeo Colacitti | last post by:
Hi, Does anyone here have a strong understanding for the meanings of the terms "lvalue" and "rvalue" as it pertains to C, objects, and different contexts? If so please share. I've been...
9
by: Kavya | last post by:
These were the questions asked to me by my friend 1. Operator which may require an lvalue operand, yet yield an rvalue. 2. Operator which may require an rvalue operand, yet yield an lvalue. ...
14
by: nobrow | last post by:
Yes I know what lvalue means, but what I want to ask you guys about is what are all valid lvalues ... a *a a *(a + 1) .... What else?
6
by: Lighter | last post by:
How to read "The lvalue-to-rvalue, array-to-pointer, and function-to- pointer standard conversionsare not applied to the left expressions"? In 5.18 Comma operator of the C++ standard, there is a...
6
by: Yarco | last post by:
I've alway thought lvalue means Left Value and rvalue means Right Value before i've read someone's article. It is said "lvalue = location value" and "rvalue = read value". Which one is right, then?
9
by: usao | last post by:
Does anyone have an example of how to create a class which describes and array, such that I can use the subscript operator on both the left and right side of an assignment statement? This is as...
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
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.