473,508 Members | 2,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is the result of a[++i] = i ; ?

1 New Member
if a[3]={-1,-2,-3};
i=0;
what a[++i] = i work?
Apr 17 '13 #1
3 1489
vijay6
158 New Member
Hey mxy0226,

The value of 'i' (1 - One) will assign to a[1].

Workflow:

1) This statement evaluate from right to left.

2) In the right hand side, no changes. The value of 'i' remain as it is (i=0).

3) In the left hand side, first '++i' statement will execute. i.e., The value of 'i' incremented by 1. Now 'i' is 1.

4) Finally the assignment statement execute. a[1] = 1 (Because now 'i' value is 1).

5) After that statement (a[++i] = i) the array 'a' will look like this a[3] = {-1, 1, -3};
Apr 17 '13 #2
VanessaMeacham
31 New Member
HI ! this operator perform right to left so vijay6's answer is right. it also overloads.
Apr 17 '13 #3
Banfa
9,065 Recognized Expert Moderator Expert
Actually the behaviour is undefined because you are accessing a variable (i) more than once between sequence points where one of those accesses modifies the value of the variable.

You do not know what order the 2 sub-expressions of the = operator are evaluated in, it is not specified in the standard.
Apr 17 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

303
17421
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
19
3594
by: Arthur T. Murray | last post by:
A C++ AI Weblog for implementing artificial intelligence is at http://mentifex.virtualentity.com/cpp.html -- with C++ source. Arthur T. Murray -- http://doi.acm.org/10.1145/307824.307853 -- ACM...
1
1715
by: david.goodyear | last post by:
Hi, I have a query that gives me almost the results I want, which is SELECT ai.entry_date as CallTime, ai.agent_login as AgentsLogin, ai.campaign as MarketingCampaign, ai.agent_input2 as...
10
8490
by: Simon Brooke | last post by:
I'm struggling to understand what 'exclude-result-prefixes' does and is for; the language of the standard http://www.zvon.org/xxl/XSLTreference/W3C/xslt.html#literal-result-element is not...
2
1621
by: nani | last post by:
Hi friends I am creating one web application in that i take one hyperlink control.when i click hyperlink control.how to split the page in two parts and display the result in that secound part If...
2
1460
by: Robert | last post by:
dear sir: I have read the c++ primer plus 5 book, and do the chapter 12 programming exercises question 5, but the average_wait have negative result. I don't understand why? here is the code,...
7
4605
bugboy
by: bugboy | last post by:
Hi, I'm just learning PHP. I want to redirect the user, after hitting submit, either to the same page displaying the results (as it is now) or if no results are found then send them to a new page...
33
5642
by: James H. Newman | last post by:
I have a portion of code along the following lines: volatile unsigned char x ; unsigned int f(unsigned char *y) ; When I do unsigned int z = f(&x) ;
22
1573
by: Curious | last post by:
I'm developing a proprietary system in C#.NET. The assembly is in a folder accessible by outside people. Since it's critical that others don't know what it's about and how it's implemented, I...
4
1894
by: donthomasino | last post by:
#include <iostream> #include <queue> using namespace std; void main() { int encode = {3,1,1,1,3,1,1,1}; queue<char>myMagicWord; myMagicWord.push('c'); myMagicWord.push('o');...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7336
Oralloy
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,...
0
7405
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
7066
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
4724
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
3214
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...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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 ...
0
435
bsmnconsultancy
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...

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.