Daddy Amateur Mom Learning: C-Language Basics-pointers (pointer variables) Learning notes

Source: Internet
Author: User

the definition of a pointer variable: the variable that holds the address is called the pointer variable1. The general form of defining pointer variables is as follows: type name * pointer variable name 1,* pointer variable Name 2, ... * pointer variable name n; For example: int * X, *y, *z; equivalent to: int * X; int * Y; int * Z; Example:

#include <stdio.h>
void Main ()
{
int x = 1;
int y = 2;
int* A; Declares a pointer variable a that points to an shaping variable
int* B; Declares a pointer variable B that points to an integer variable

A = &x; Assign the X address to the pointer variable A, (A is equivalent to an address, and by &x, the address of X is pointed to a)
B = &y; Assign the Y address to pointer variable B. Ditto

printf ("x =%d \ n", *a); If the pointer variable points to a normal variable (that is: A = &x), then the pointer variable is equal to the normal variable (then: *a = x)

printf ("y =%d \ n", *b); Ditto

This shows that *a is equivalent to X, and because after assigning a value, A is equivalent to &x, then *&x equals x, so * and & inverse each other.
}

Daddy Amateur Mom Learning: C-Language Basics-pointers (pointer variables) Learning notes

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.