C-loops, several ways to get the address of an array

Source: Internet
Author: User

The role of the program's debugging: To track the CPU execution code steps to monitor how variable values change during program execution Do-while and while in real development, do-while is less useful because even if the loop is executed at least once, the while can be done There are two types of loops: 1. Cycles determined by cycles 2. Cycles with indeterminate cycles, but determines the conditions for the loop to continue to live the end of the condition for an array of 1. Ways to get the address of a[i]
1  &a[i]  //  take address characters
1 a+i  //
1  int *p = A; 2  P+i;     //   Pointer Method

2. Several methods for obtaining the value of A[i] (1) a[i] (2) * (A+i) (3) int *p = A; * (P+i);(4) * (&a[i]) if the element value of an array is a pointer, then this array can be called a pointer array pointer array is a set of ordered pointers. All elements must be pointer variables that have the same storage type and point to the same data type. General Declaration form:
1 int *array[];
Use:
1 int 3 4,  5; 2 int *pa[3] = {&a, &b, &c};
where Pa[0] A addresses the first address of the PA array = &pa[0] Brainstorming
1 intarr[2][2] = {1,2,3,4}; 2 int*pa[2] = {arr[0], arr[1]};3  4printf"arr[0][0] =%p\n", &arr[0][0]); 5 //Arr[0][0] Address, the first address of Arr6printf"arr[0][0] =%d\n", arr[0][0]); 7 //value of arr[0][0]8printf"pa[0] =%p\n", pa[0]); 9 //Pa[0], which is the address pointed to by the pointer pa[0], the addressTenprintf"*pa[0] =%d\n", *pa[0]);  One //Pa[0] The content of the address pointed to Aprintf"**pa =%d\n", **PA);  - //The value corresponding to the value of the first address of the pointer array pa (that is, the address of the pa[0], the address of the pa[0] store-that is, arr[0] -printf"* * (pa+1) =%d\n", * * (pa+1));  the //The value corresponding to the value of the first address of the pointer array pa +1 (not a number 1, 1 of the address meaning) (that is, the address of the pa[1]) (that is, pa[1] The address of the stored content-that is, arr[1]
1  intA =3, B =4, C =5, d =6;2     int*pa[4] = {&a, &b, &c, &d};3  4printf"A =%d\n", a); 5        //content of a6printf"&a =%p\n", &a); 7 //Address of a8printf"pa =%p\n", PA); 9 //the first address of the array, &pa[0]Tenprintf"pa[0] =%p\n", pa[0]);  One //The 1th element of the array, the address of a Aprintf"*pa[0] =%d\n", *pa[0]);  - //The contents of the memory address that the 11th element of the array points to -printf"* (&a) =%d\n", * (&a));  the //content of a -printf"**pa =%d\n", **PA);  - //content of a

Arithmetic operations between pointer variables Note: Only the two pointer variables that point to the same array can be operated on, otherwise the operation is meaningless in nature. (Pointer2 address value-pointer1 address value)/sizeof (data type) Usage: 1. Determine whether the element that the two pointer variable is pointing to is 2 consecutive. Determine the number of elements separated by two pointer variables:
1 int a[5] = {1,2,3,4,5}2int *p =3int *p1 = &a[3]

C-loops, several ways to get the address of an array

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.