12-10 about pointers

Source: Internet
Author: User

I. One-dimensional arrays

1?? Clear the number of elements 2?? Cannot make variable 3?? Index value =04?? The array name is the first address of the array

Two. Pointers

① type of pointer

such as int *//integer pointer

char *//String pointer

FLOAT *//floating-point pointer

Note: Pointers can only point to a block address and cannot be given a constant value.

The role of ②*

1?? Define a pointer variable

2?? * (pointer variable) = = Gets the value of the variable pointed to by the pointer

Cases:

int a = 10;

int *p = &a;

*p = 10;

③int a = 10;

(*PA) + + = a++ = 11;

* (pa++) = * (the next memory space of a)//the Next memory space is the original memory address value + 4 bytes

Pointer variable takes 8 bytes in 64-bit system

Example: char a[10] = {}

Char *pa =a; represents the first address of array A

*pa the first address of an array a

Three. Const a//CONST defines a variable a as a constant

Constant pointer: const INT*PA = &a

PA=20//Error: (Cannot change the direction pointed to by the pointer)

Pa=&b//Correct: (Can change the direction of the pointer)

Pointer constants

int *const PA = &a;

*PA = 20/correct (can change the value pointed to by the pointer)

Pa=&b//error (Can not change pointer direction)

Constant pointer to constant

const INT * Const PA = &a;

*pa = 20;

PA =&a;

Cannot add const before a sort variable

12-10 about pointers

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.