The most wronged keyword----sizeof

Source: Internet
Author: User

 
sizeof is the keyword is not a function, in fact, even if you do not know whether it is 32 keywords, we can also use the compiler to determine its identity. Look at the following example:
int i=0;
A), sizeof (int); B), sizeof (i); C), sizeof int; D), sizeof I;

There is no doubt that the value of the 32-bit system under a), B) is 4. What about the C)? D)? Under the 32-bit system, we found that the result of D was also 4.

Hey? What about the parentheses behind sizeof? Without parentheses, you can do it, so think about the function name without parentheses. It is easy to conclude that sizeof is not a function.

OK, look at C again). How does the compiler suggest an error? Not that sizeof is a keyword, and that the parentheses behind it are not available? Well, what do you think about sizeof int? int preceded by a keyword? Type extension? Obviously incorrect, we can add unsigned,const and other keywords before int but cannot add sizeof.

<blockquote> Well, remember: sizeof the parentheses can be omitted when calculating the space size of the variable, and the type (die) size cannot be omitted. Under normal circumstances, we also do not steal this lazy, obediently write the parentheses, continue to act as a "function", do a "phi function skin keyword." </blockquote>

Do my keywords and let people think it's a function to go.
&nbsp;
&nbsp;
Leave a few questions (explained in detail with pointers and arrays), under 32-bit systems:
int *p = NULL;
What is the value of sizeof (p)?
What about sizeof (*P)?

int a[100];
What is the value of sizeof (a)?
What about sizeof (a[100])? Please pay particular attention to this example.
What about sizeof (&A)?
What about sizeof (&a[0])?

int b[100];
void fun (int b[100])
{
sizeof (b);//What is the value of sizeof (b)?
}

The most wronged keyword----sizeof

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.