C language Pointer 1

Source: Internet
Author: User

#include  <stdio.h>/*2018-05-26 address is the number of memory cells pointer is the address, The address is the pointer address is the memory unit number pointer variable is the address of the variable pointer (0019ff38) and pointer variable (p) is two different concepts but note: We usually describe the pointer variable as a pointer, the actual meaning is not the same */int main (void {Int * p;      // p is the name of the variable, int * represents the address of the int type variable that the p variable holds    // int *p  does not mean to define a variable named *p   // int *p  should understand this: p is the variable name, the data type of the p variable is int  * type   //The so-called int * type is actually the type that holds the INT variable address int i = 3;int j;p = &i;   //ok /*1,p Save the address of I, so P point to i2,p is not i,i nor p, more accurately, the value of the modified P does not affect the value of I, modify the value of I will not affect the value of P 3, if a pointer variable points to a common variable, then * The pointer variable is exactly the same as the normal variable example: if P is a pointer variable, and p is the address of the normal variable I, p points to the ordinary variable i*p  is exactly the same as I or say: In all occurrences of *p can replace I in all occurrences of I can be replaced by *pprintf ("%d\n", i),  //output 3printf ("%d\n", *p),  //output 3*p  is the variable */j = *p;printf with the content of P as the address ("i =  %d ,j = %d ,*p = %d \n ", i,j,*p);   //results i = 3  , j = 3 ,*p = 3printf ("I's address is:%p\n", &i); &nbsThe%p used in the p; //c language to output the value of the pointer type itself. This means that%p is used to output the address printf ("J's address is:%p\n", &j);p rintf ("P's address is:%p\n", &p);p rintf ("P's value is:%p\n", p);/* Output: i = The address of the  3 ,j = 3 ,*p = 3i is: 0019ff38j address is: 0019ff34p address is: 0019FF3CP value is: 0019FF38*/ return 0;} The address of the variable i is the value of 0019ff38,i is the 3//variable p is the address of the 0019ff3c,p value is 0019ff38, that is, the value of P is the address of I//*p  is the content of P as the address (that is, I address 0019ff38) variable, so * The value of P is 3//note that the address is definitely not the case when you run it, but the address of I and the value of P must be the same

C language Pointer 1

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.