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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:39:28+00:00 2026-05-16T10:39:28+00:00

int main() { int i=3; (++i)++; printf(%d,i); } This programs works with g++ compiler

  • 0
int main()
{
   int i=3;
   (++i)++;        
   printf("%d",i);
}

This programs works with g++ compiler but not gcc.
If i write i++++ or ++i++ it doesn’t work in cpp also.
I think there is difference between c-expression and c++-expression.
Can somebody explain about L-value and R-value ?

  • 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-16T10:39:29+00:00Added an answer on May 16, 2026 at 10:39 am

    Edit: This answer is incorrect for the updated question, it applies to the question as originally stated.

    (i++)++ shouldn’t work with either gcc or g++, whether or not they are parsing the file as C or C++ in both languages postfix increment requires an lvalue as an operand and the result is an rvalue.

    (Note that rvalue is only used formally in C++. In C the results of expressions are either explicitly lvalues or they’re just not lvalues. The term rvalue isn’t used in the normative text of the C standard at all.)

    Simplisticly, an lvalue is an expression that refers to an object, i.e. conceptually a region of storage somewhere. A modifiable lvalue is something that it is valid to assign to so can appear on the left hand side of an assignment expression.

    An rvalue is just a value, something that you can assign a modifiable lvalue from, but not something that you can assign to. It can only appear on the right side of an assignment expression.

    g++ gives me the error: lvalue required as increment operand.

    Prefix increment (and decrement) are slightly different. In C++ the result of a prefix increment is explicitly an lvalue (5.3.2/1 [expr.pre.incr]); in C it is explicitly not an lvalue (6.5.3.1 states that ++E is equivalent to (E+=1); 6.5.16 says that the result of any assignment is not an lvalue).

    (++i)++ is, therefore, semantically correct only in C++, however it has undefined behaviour because you are storing a value to an object twice without an intervening sequence point.

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

Sidebar

Related Questions

In this code: int main(int a, int b) { printf( main(int, int) works \n\n);
int main() { int *d=0; printf(%d\n,*d); return 0; } this works fine. >cc legal.c
This is my program: int main(int argc, char *argv[]){ if(argc != 2){ printf(Uso: ./server
I have this code: #include <stdio.h> #include <openssl/sha.h> #include <openssl/ssl.h> int main(){ printf(OpenSSL version:
Consider this code: void res(int a,int n) { printf(%d %d, ,a,n); } void main(void)
$ printf 'int main(){}' | gcc -static -x c - -o hello $ scp
Consider this program: #include <stdio.h> int main() { printf(%s\n, __FILE__); return 0; } Depending
c program compiler gcc I have 3 files. main.c stop_watch.h and stop_watch.c This program
I compile this program: #include <stdio.h> int main() { printf(Hello World!); return 0; }
In this c program #include<stdio.h> int main() { #if UnDefinedSymbolicConstant==0 printf(UnDefinedSymbolicConstant is equal to

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.