C language pointer 2 (null pointer, wild pointer)

Source: Internet
Author: User

Recently, a friend jokingly asked if int *p * is a pointer or p is a pointer or *p is a pointer, of course, know that p is the pointer

Wild pointer----->>> refers to a pointer that does not point to an address (refer to the previous article for the pointer to the address)

Null pointer---->> pointer to null (NULL) is a null pointer

Other uses of pointers, pointers can point to pointers, pointers can be +-*/operations

/*

Note that each compiler is not the same, there is a wrong way of writing, such as:

int *p,int a=10,b=20;

p=&b;

*p = &a; Cause of Error: *p represents the value that pointer p points to, and &a represents the address of a, the value cannot be equal to an address, the correct notation bit: *p=a; the value of the pointer p to the address is equal to the value of a, which is now b=a=10

Of course, each compiler is different, the individual compiler can compile, print out the *p value is a strange number, this number is not garbled, but a random number, and the address of this random number is a development of the memory value, and this time the pointer p is a wild pointer

*/

The hazard of the wild pointer is quite large, because the wild pointer does not know to point to which block of memory, if the programmer accidentally uses the wild pointer, then may obtain the data which does not want to obtain, very likely causes the program to crash, the flash back and so on danger/harm, after I repeatedly knocked out the wild pointer, discovered a wild pointer harm law, The greater the hazard of the wild pointer

C language pointer 2 (null pointer, wild pointer)

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.