The sizeof of the C-language plane question

Source: Internet
Author: User

<title>The sizeof of the C-language plane question</title> The sizeoftable of the question of C language face Contents
    • 1. sizeof
1sizeof

sizeof is the length character of the data type or expression in C, it is not a function, and the calculation of the number of bytes in the program compiles
Not be counted during the execution of the program! (Literary not good, I will nonsense down, the next point)!

  #include
 
   
    
   int main (int argc, char* argv[]) {    char str[]= "123";    char *p=str;      printf ("%d\n", sizeof (' a '));  =4    printf ("%d\n", sizeof ("a"));  =2    printf ("%d\n", sizeof (str));  =4    printf ("%d\n", sizeof (p));    =4/8    printf ("%d\n", sizeof (*P));   =1        return 0;  }
 
   
    • sizeof (' a ') = = 4 known as ' A ' corresponding ASCII code value is 97, that is ' a ' ==97, in other words
      sizeof (' a ') is equivalent to sizeof (97); In other words, the compiler handles it as an integer constant int
    • sizeof ("a") = = 2 No need to explain, you know.
    • sizeof (str) = = 4 asks for the size of the array footprint
    • sizeof (p) = = 4 or 832-bit systems no matter what type of pointer, the size is 4 bytes
      64-bit systems no matter what type of pointer, the size is 8 bytes
    • sizeof (*P) =1 equivalent to sizeof (STR1)
Footnotes:1

DEFINITION not FOUND.

Date:a date, fixed, of a format string for format-time-string

Author: Wild Book

Created:2016-07-24 Day 11:47

Emacs 24.5.1 (ORG mode 8.2.10)

The sizeof of the C-language plane question

Related Article

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.