directory of this document
First, what is a null pointer and a wild pointer
Two examples of wild pointers and null pointers
Description: This objective-c topic is a prelude to learning iOS development, and to enable programmers with experience in object-oriented language development to quickly get started with objective-c. If you do not have programming experience, or are not interested in
I. Examples
A two-dimensional array can be replaced by a pointer pointing to an array, while a pointer array can be replaced by a pointer pointing to a pointer.
# Include
For an array with a determined type, the element type and the number of elements are determined; the array degrades to the corresponding
I. Usage of typedef:
①Define a type of Alias, not just a simple macro replacement. It can be used to declare multiple objects of the pointer type at the same time. Trap: typedef char * tchar;
Tchar Pa, PB; // Pa and Pb are pointer types. # Define cannot achieve this effect.
Trap: typedef char * pstr;
Int mystrcmp (const pstr, const pstr); const pstr is equivalent to char? No, it is actually equivalent to ch
How does the pointer Parameter Pass the memory ?, Pointer parameter transfer memory
If the function parameter is a pointer, do not expect this pointer to apply for dynamic memory.The Test function's statement GetMemory (str, 200) does not enable str to obtain the expected memory. str is still NULL,
Why?
Void GetMemory
Normal 0 7.8 磅 0 2 false false false MicrosoftInternetExplorer4
Please repost the source from a friend
I. What is a pointer?
It is important to clarify what a pointer is. This is the source of the topic we are discussing. Before explaining what a pointer is, let's take a look at the concept of a variabl
Pointer array, array pointer, function pointer:
1. pointer array: the data items of the array are pointers. The most common is the string pointer array. See the following example:
Char * cities = {"Jinan", "Qingdao", "biejing", "Shanghai", "Wulumuqi "};
Note the initializati
These two names are different, of course, the meanings they represent are different. I just started to see this scare, mainly Chinese is too broad and profound, the whole such abbreviation is too professional, people are around dizzy. It is easier to understand from the English explanation or the Chinese full name.Pointer array: array of pointers, which is used to store pointers to arrays, which are arrays of elements that are pointersArray pointer: A
Two-dimensional array name and second-level pointer, two-dimensional array pointer1. pointer
1.1 a pointer contains two aspects: a) address value; B) the data type pointed.
1.2 The dereference operator (dereference operator) will be based on the current address value of the pointer and the data type to which it points,
ArticleDirectory
Instance 1:
Instance 2:
Instance 3:
Instance 4
For pointers and constants, the following three forms are correct:
Const Char* Myptr = Char_a; // pointer to a constantChar*ConstMyptr = Char_a; // constant pointerConst Char*ConstMyptr = char_a; // constant pointer to a constant
The three types are described in sequence below.
Because * The operator is the le
Const pointer and pointer to const
There are two meanings when using a pointer with Const. One means that you cannot modify the content of the pointer, And the other means that you cannot modify the content pointed to by the pointer. It sounds a bit confusing. Let's give a
C Language -- pointer, pointer
1. What is a pointer?
"Pointer variable" refers to the variable used to store the variable address. A pointer variable is also a variable. The difference between it and other variables is that it stores not ordinary data, but the
For pointers and constants, the following three forms are correct:
Copy Code code as follows:
const char * myptr = char_a;//pointer to constant
char * Const MYPTR = pointer to char_a;//constant
const char * Const MYPTR = char_a;//constant Pointer to constant
The following three types are described in turn.
Because the * operator is the
Mind Map
This section describes the pointer and array (1) in the previous Article C. Pointers and arrays -- perform expansion above
Do you know what X = y is like during compilation and running?
Character pointer and function 1> A string is an array of characters ending with '\ 0. For example, printf accepts a pointer pointing to the first character in the
solution is,Check whether the pointer is null before using the memory. If the pointer P is a function parameterUse assert (P! = NULL. If you use malloc or new to apply for memory, you should use if (P = NULL)Or if (P! = NULL.
?? Although the memory allocation is successful, it is referenced before initialization.
?? The memory allocation is successful and initialized, but the operation is beyond the memory
#include void Main (){int a[5]={1,2,3,4,5};int *ptr= (int *) (a+1);printf ("%d,%d", * (a+1), * (ptr-1));return;}output is: 2,5If int*ptr = (int*) (a+1) is converted to int* ptr= (int *) (a+1) then the output is 2,1Explanation:* (a+1) is actually very simple refers to a[1], the output is 2.The problem is the second point, what is the output of the * (PTR-1)? as explained below, a+1 is not the first address +1, the system will consider adding an entire array of a, which offsets the size of the ent
Give yourself a wave of self-dismissal ~Introduce pointer constants and constant pointers firstconst int *p; This is a pointer constant int const* p; This is a constant pointer.Const is a constant modifier, and the modifier is a constant, and the characteristic of a constant is that it cannot be changed.The pointer constants are introduced first,const int *p;
When pointers and arrays are passed into functions as arguments, the incoming address, which points to the address of the variable and the first address of the group, can change the value of the pointer or array in the function, but in essence they are the passing of the value (which is passed by the value of the variable, which does not change the original value of the argument). , we cannot operate on pointers and array addresses (e.g., address assi
Description of the complex type:Pointers: 1. Type of pointer: Remove the pointer name in the statement that declares the pointer, and the rest is the type of the pointer 2. The type that the pointer points to: Remove the declarator * and
When the object layout is known, the address is adjusted when the C ++ Object Pointer is converted, and the layout pointer
I noticed this problem when debugging and researching the netscape browser plug-in development. That is, when the object layout is known (that is, there is an inheritance relationship between objects), pointers of different types of objects are converted (whether implicit conversion fro
first, what is a null pointer and a wild pointer1. Null pointer 1 > A pointer that does not store any memory address is called a null pointer (null pointer ) 2> null pointer is a po
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.