[Study Notes] [C Language] sizeof, Study Notes sizeof

Source: Internet
Author: User

[Study Notes] [C Language] sizeof, Study Notes sizeof

1. used to calculate the memory bytes occupied by a variable, a constant, or a data type.

2. sizeof has three forms

1> sizeof (variable \ constant)

Sizeof (10); char c = 'a'; sizeof (c );

2> sizeof variable \ constant

Sizeof 10; char c = 'a'; sizeof c;

3> sizeof (data type)

Sizeof (float );

Note: it cannot be written as sizeof float;

3. Code
1 # include <stdio. h> 2 3 int main () 4 {5 // int size = sizeof (10); 6 // int size = sizeof 10.9; 7 8 int a = 10; 9 10 // int size = sizeof (a); 11 // int size = sizeof a; 12 13 int size = sizeof (char); 14 // int size = sizeof char; // The error code 15 16 printf ("size = % d \ n", size); 17 18 return 0; 19}

 

 

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.