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 8283075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:36:23+00:00 2026-06-08T10:36:23+00:00

Is the following undefined or implementation-defined: int x = 0; printf(%d%d, ++x, x); The

  • 0

Is the following undefined or implementation-defined:

 int x = 0;
 printf("%d%d", ++x, x);

The order of evaluating arguments is unspecified, so:

  • if ++x is evaluated first, this prints 11.
  • if x is evaluated first, it prints 10.
  • 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-08T10:36:24+00:00Added an answer on June 8, 2026 at 10:36 am
    printf("%d%d", ++x, x);
    

    This is clearly undefined behavior in C++.

    (C++11, 1.9p15) “If a side effect on a scalar
    object is unsequenced relative to either another side effect on the same scalar object or a value computation
    using the value of the same scalar object, the behavior is undefined.”

    Same for C (emphasis mine):

    (C99, 6.5.p2) “Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression.72) Furthermore, the prior value shall be read only to determine the value to be stored.73″

    Note that C11 has now a similar wording as in C++11:

    (C11, 6.5p2) “If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined.”

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

Sidebar

Related Questions

Possible Duplicate: Regular cast vs. static_cast vs. dynamic_cast Undefined, unspecified and implementation-defined behavior I
Does the following program invoke Undefined Behaviour in C? int main() { printf(Printf asking:
In the following implementation of the mediator pattern why this.name in the initialize method
Is it true that the following yields undefined behavior: void * something = NULL;
The following code results in undefined for lastIndex: var a = /cat/g; var l
The following variable my_cords is undefined when it gets to the google maps function,
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like
The following is not working because @only is undefined (stated 30 times in the
I get the following notification on many pages: Notice: Undefined variable: jump_link_target in include()
I get the following error: 1119: Access of possibly undefined property color through a

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.