c--pointer

Source: Internet
Author: User

In the C language, pointers are also variables, and pointers hold memory addresses.

Reference to the pointer:

int a = 0;

int * person = &a;//can be taken to the address of variable a

printf ("\d\n", *person);//The value corresponding to variable a

Pointers as function parameters: pointers as parameters of the function, the address of a variable to the function inside, you can make judgments in the inside of the change.

Pointers as function return values: Note that if the returned pointer is local, you need to decorate the variable with static, otherwise there is a warning.

void *: Void type pointers are generally used for void*, common types;

Array of pointers: int arr[] = {1,2,3,4};

As defined in an int array, int * p = &arr; gets to the first address of an ARR array, generally the int type takes up 4 bytes, so the data behind the array can be taken out.

Note: The length of an array can be obtained by sizeof (ARR)/sizeof (int).

c--pointer

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.