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

  • Home
  • SEARCH
  • 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 4026588
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:59:21+00:00 2026-05-20T10:59:21+00:00

Possible Duplicate: What is more efficient i++ or ++i? No difference between these: i++;

  • 0

Possible Duplicate:
What is more efficient i++ or ++i?

No difference between these:

i++;
++i;

But when using them like this:

anArray[ i++ ] = 0;
anArray[ ++i ] = 0;

Is there a difference?

TO BE EDITED:
Thanks

  • 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-05-20T10:59:22+00:00Added an answer on May 20, 2026 at 10:59 am

    Yes! Big difference!

    i++ increments i after the line of code is executed expression is evaluated. ++i increments it before. For example:

    int i = 2;
    printf("%i\n", i++); //prints "2"
    printf("%i\n", i);   //prints "3"
    

    Compare with:

    int i = 2;
    printf("%i\n", ++i); //prints "3"
    printf("%i\n", i);   //prints "3"
    

    And I’ve heard that ++i is ever so slightly faster. Here is more on that.

    Hope this helps!

    UPDATE 2: Killed the last update, since the code technically had undefined behaviour. Moral of that story: Don’t use foo(i, ++i), foo(++i, ++i), foo(i++, i), etc. Or even array[i] = ++i. You don’t know what order the expressions get evaluated in!

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

Sidebar

Related Questions

Possible Duplicate: What is a ‘Closure’? I read more and more about closures but
Possible Duplicate: Is there a more efficent way to randomise a set of LINQ
Possible Duplicates: Implementing a matrix, which is more efficient - using an Array of
Possible Duplicate: How can I find the missing value more concisely? Is there a
Possible Duplicate: What is Erlang written in? I hear somewhere erlang is more efficient
Possible Duplicate: More efficient way of updating UI from Service than intents? I have
Possible Duplicate: Technically why is processes in Erlang more efficient than OS threads? Any
Possible Duplicate / a more recent/less clear question Branch from a previous commit using
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: How do you send email from a Java app using Gmail? How

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.