[Study Notes] [C Language] memory Analysis of variables, learning notes C language Variables

Source: Internet
Author: User

[Study Notes] [C Language] memory Analysis of variables, learning notes C language Variables
1. bytes and address

To better understand the storage details of variables in the memory, first let's take a look at the "Byte" and "Address" in the memory ".

1> memory in bytes"

The above statement is not recommended.

 

3. course code

 

1 # include <stdio. h> 2 3 4 // 1. memory addressing ranges from large to small, and the bytes with a large memory address are preferentially allocated to variable 5 6 // 2. the more defined the variable, the larger the memory address is. get the address of the variable: & variable name 9 10 // 4. output address: % p 11 12 // 5. a variable must be initialized before it can use 13 14 15 int main () 16 {17 // memory addressing from large to small 18 int a = 10; 19 20 int B = 20; 21 22 int c; 23 24 // & is an address operator. The obtained variable address 25 // % p is used to output the address 26 // 0x7fff56f09bc8 27 printf ("the address of a is: % p \ n ", & a); 28 // 0x7fff56f09bc4 29 printf (" B address: % p \ n ", & B ); 30 // 0x7fff56f09bc0 31 printf ("c Address: % p \ n", & c); 32 33 // Since variable c has not been initialized, so it is wrong to use it directly. 34 // int d = c + 1; 35 36 37 printf ("the value of c is % d \ n", c ); 38 39 return 0; 40 41}

 

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.