Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7743989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:40:09+00:00 2026-06-01T09:40:09+00:00

a[i] = i++; Why does the above code not work? What is wrong with

  • 0
a[i] = i++;

Why does the above code not work?

What is wrong with above code? I am asking this question to improve my knowledge.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:40:09+00:00Added an answer on June 1, 2026 at 9:40 am

    Because the ISO standard says that you are not allowed to change a variable more than once (or change and use one) without an intervening sequence point.

    There is no sequence point between the use of i in a[i] and the change of i in i++.

    The list of sequence points from C11 (not really changed that much since C99) are described in Annex C:

    • Between the evaluations of the function designator and actual arguments in a function call and the actual call.
    • Between the evaluations of the first and second operands of the following operators: logical AND &&; logical OR ||; comma ,.
    • Between the evaluations of the first operand of the conditional ?: operator and whichever of the second and third operands is evaluated.
    • The end of a full declarator: declarators;
    • Between the evaluation of a full expression and the next full expression to be evaluated. The following are full expressions: an initializer; the expression in an expression statement; the controlling expression of a selection statement (if or switch); the controlling expression of a while or do statement; each of the expressions of a for statement; the expression in a return statement.
    • Immediately before a library function returns.
    • After the actions associated with each formatted input/output function conversion specifier.
    • Immediately before and immediately after each call to a comparison function, and also between any call to a comparison function and any movement of the objects passed as arguments to that call.

    and 5.1.2.3 Program execution states:

    Evaluations A and B are indeterminately sequenced when A is sequenced either before or after B, but it is unspecified which.

    The presence of a sequence point between the evaluation of expressions A and B implies that every value computation and side effect associated with A is sequenced before every value computation and side effect associated with B.

    Section 6.5 Expressions pretty much covers your exact case:

    If there are multiple allowable orderings of the subexpressions of an expression, the behavior is undefined if such an unsequenced side effect occurs in any of the orderings.

    This paragraph renders undefined statement expressions such as i = ++i + 1; and a[i++] = i; while allowing i = i + 1; and a[i] = i;.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<asp:TextBox ID=tbName CssClass=formField MaxLength=<%=Constants.MaxCharacterLengthOfGameName %> runat=server></asp:TextBox> The code above does not work. I can
I found the following code in SO. Does this really work? String xml =
The reloadData does not work. Code : - (void)viewDidLoad { allOnMapButton.hidden = YES; volLocApp
QUESTION: how to get at the star above the numbers My FIDDLE currently does
Any idea why my image does not horizontally line up with the text above
^([0-9]*[1-9][0-9]*(\.[0-9]+)?|[0]+\.[0-9]*[1-9][0-9]*)$ I don't know regular expression well. Above regular expression does not allow input
I use PHP and Simple XML. I use a loop that does not work
This question is very much related to: A) How to separate CUDA code into
I get reports that a button does not work in my webapp on IE8
I am not sure whats wrong with my code. delimiter $$ CREATE TRIGGER updateRestaurantAtributes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.