Parse a topic about sizeof usage--sizeof (i++) _c language

Source: Internet
Author: User
Copy Code code as follows:

#include <stdio.h>
int main ()
{
int i;
i = 10;
printf ("%d\n", I);
printf ("%d\n", sizeof (i++));
printf ("%d\n", I);
return 0;
}

What should these three lines of output be?
The answer is:
10
4
10
The third one, why not 11? Why did I not increase myself?
Please see the C + + standard;
5.3.3 sizeof
The sizeof operator yields the number of bytes in the object representation to its operand. The operand is either a expression, which are an unevaluated operand (Clause 5), or a parenthesized type-id.
That is, if the operand of the sizeof is an expression, the expression will not be computed.
sizeof when preprocessing look on the line, it is behind the parentheses, it is not evaluated at all, only according to the C of a pile of rules to determine the result type, and then return the size of the result type
The same is true of the other operator typeID.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.