In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are wild pointers and null pointers of C language". In daily operation, I believe that many people have doubts about what wild pointers and null pointers of C language are. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what are wild pointers and null pointers of C language". Next, please follow the editor to study!
One: wild pointer
Concept: the memory address that the wild pointer points to is unknown (random, incorrect, and unrestricted).
Description: pointer variables are also variables, which can be assigned at will. However, it doesn't make sense to assign any numeric value to a pointer variable, because such a pointer becomes a wild pointer, and the area the pointer points to is unknown (the operating system does not allow you to manipulate the area of memory that the pointer points to).
Note: the wild pointer will not cause an error directly, but the memory area pointed to by the wild pointer will cause a problem.
Code example:
Int a = 100 leading int * ptrac p = a; / / assigning the value of a to the pointer variable pMagee p is wild pointer, ok, it will not be a problem, but there is no meaning p = 0x12345678; / / assigning a value to pointer variable p, p is wild pointer, ok, there will be no problem, but it is meaningless * p = 1000; / / it is not possible to assign a pair of wild pointers
Assigning the value of a to the pointer variable pMagep is a wild pointer, ok, which is not a problem, but it doesn't make sense.
Assign a value to the pointer variable p, p is a wild pointer, ok, it won't be a problem, but it doesn't make sense.
1.1: the cause of the wild pointer
1. Pointer uninitialized: the pointer variable does not automatically become a NULL pointer when it is created, its default value is random, and the space it refers to is random.
Code example:
Int main () {int * p; * p = 20; return 0;}
(personal understanding: pointer variables are randomly assigned by the operating system, do not point to a specific space, do not have a foothold)
two。 Pointer out-of-bounds access: the pointer points beyond a reasonable range, or returns a pointer or reference to stack memory when a function is called, because the function is released at the end of the stack.
Code example:
Int main () {int arr [10] = {0}; int * p = arr; for (int I = 0; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.