Melted down-c/C + + knowledge-all-Stack Road

Source: Internet
Author: User

  
C language Handout pointer importance, some people say that learning C language, did not learn the pointer is equivalent to not learning C language, and I am unfortunately, university time is, learned C language, but did not learn the pointer

1 //C language functions to be declared after use we want to unify2#include <stuio.h>3 //function Declaration4 voidtest ();5 intMain ()6 {7 test (); 8 return 1; 9 }Ten One voidTest () A { -printf'Hello world!\n'); -}


Computer, the minimum memory unit is byte, each byte of memory has a unique number, this number is the memory address, under the 32-bit system is a 32-bit integer, under the 64-bit system, is a 64-digit integer

int Main () {int a=0; int *p=&a; // this is wrong. // The address is an integer, but the address is a special integer that cannot be manipulated directly through the certificate . int *p1; // define a variable, named P1, that can point to an int's address

Right, like this.

int x=1;

int *p;
P=x;
printf (*p);//print 1
}

The null pointer and the wild pointer,

In the program to avoid the existence of the wild pointer, because the wild pointer will cause the program to collapse, allowing the existence of NULL pointers in the program

The wild pointer is a pointer to no address

A null pointer is a pointer to a null address

 int   main () { int  a=1 ; int  b=2 ; int  c=3  ;  int  *p;p  =* A;  *p=10  ;p  =& B;  *p=20  ;p  =& C;  *p=30  ;p rintf (  " a=%d,b=%d,c=%d   ", a,b,c); 
}

C language can directly manipulate memory, white is the pointer directly operating memory, which is quite invincible thing!

Pointer constants and pointers to constants---

Constant pointers cannot be randomly fingered

Found good egg pain ah, the knowledge of the pointer should review the review!

Melted down-c/C + + knowledge-all-Stack Road

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.