C/C ++ the full stack of Knowledge furnace (c), the road to knowledge Furnace

Source: Internet
Author: User

C/C ++ the full stack of Knowledge furnace (c), the road to knowledge Furnace

  
The importance of C-language handout pointers. Some people say that learning C language is equivalent to not learning C language. Unfortunately, in college, I learned C language but didn't learn pointers.

1 // in C language, the function must be declared first and then used. We need to unify 2 # include <stuio. h> 3 // function declaration 4 void test (); 5 int main () 6 {7 test (); 8 return 1; 9} 10 11 void test () 12 {13 printf ('Hello world! \ N'); 14}


The minimum unit of memory for a computer is byte. Each byte memory has a unique ID, which is the memory address. It is a 32-bit integer in a 32-bit system, in a 64-bit system, it is a 64-digit integer.

Int main () {int a = 0; int * p = & a; // This is incorrect // The address is an integer, but the address is a special integer, is an int * p1 that cannot be operated directly through the certificate; // defines a variable named p1, which can point to an int address.

// Correct like this

Int x = 1;

Int * p;
P = x;
Printf (* p); // print 1
}

 

 

NULL pointer and wild pointer,

Avoid the existence of the wild pointer in the program, because the wild pointer will cause the program to crash and allow the existence of the NULL pointer in the program

The wild pointer does not point to the 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;printf("a=%d,b=%d,c=%d",a,b,c);
}

The C language can directly operate the memory. To put it bluntly, the pointer directly operates the memory, which is rather invincible!

Pointer constant and pointer to constant ---

 

Constant pointers cannot be out of the box

 

I found it quite painful. I should review the pointer knowledge!

 

 

 

 

 

Related Article

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.