Sizeof has something to say: "You don't understand me"

Source: Internet
Author: User

First, let's make a multiple-choice question: Is sizeof a keyword or a function?

See the following example:

Int I = 0;
A), sizeof (INT); B), sizeof (I); c), sizeof int; d), sizeof I;
Undoubtedly, the value of a) and B in a 32-bit system is 4. What about C? D?

After debugging, I found that D) is also 4, and c) is an error?

This is because the function name is not followed by parentheses ~ So sizeof is a keyword, not a function ~ Remember: sizeof can be omitted when the space occupied by the computing variable is large, but not when the computing type (model) is large. Exercise: Have you mastered sizeof? (Eclipse compilation in the following 32-bit machine systems) int * P = NULL; char * q = NULL;
What is the value of sizeof (p? What about sizeof (* P? What about sizeof (q? What about sizeof (* q?
Int A [100];
What is the value of sizeof (?
What about sizeof (A [100?
What about sizeof (&? What about sizeof (& A [0?
Int B [100];
Void fun (int B [1, 100])
{
Sizeof (B); // What is the value of sizeof (B?
} Different compiling environments may be different. Please refer to us for more information ~ (⊙ O ⊙) Ah! The answer is as follows ~ Answer: sizeof (p) = 4 sizeof (* P) = 4 sizeof (q) = 4
Sizeof (* q) = 1 sizeof (A) = 400
Sizeof (A [1, 100]) = 4
Sizeof (& A) = 4
Sizeof (& A [0]) = 4
Sizeof (B) = 4

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.