Pointer suspension in C Language

Source: Internet
Author: User

Pointer floating

Pointers are easily overlooked when we use pointers. The main manifestation is: the memory pointed to by pointers.

Release, the pointer is not set to NULL, resulting in an uncontrollable pointer.

# Include

 
  
# Include

  
   
Int * pointer; void func () {int n = 8; pointer = & n; printf ("pointer point data is % d \ n", * pointer ); // pointer = NULL;} int main () {func (); sleep (2); printf ("% d \ n", * pointer); return 0 ;}

  

 


When the space is released, if this pointer is not set to NULL, the pointer will point to an unpredictable address. When it is set to NULL, a segment error (segment fault) will occur ), make us check for errors

Easy to use.



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.