){int a[3][3] = {1,2,3,4,5,6,7,8,9};int (*p) [3] = A;printf ("%d", *p[0]);return 0;}What does this piece of code output? The answer is output 1. The first thing you need to know is [] the priority of the operation is higher than the * operator, then p[0] represents the first address of a a[0] that is, and then uses the * (address) of this notation, take the value of this address, so that is the value of a[0][0], because A[0]=a[0] [0]. Let's look at the following example:#include int main (void){
1. What is an array pointer?Array pointer: A pointer to a one-dimensional or multidimensional array.For example: int * b=new INT[10]; Pointer to a one-dimensional array B; Note that this time to release the space must be delete [], otherwise it will cause memory leaks, B becomes an empty cantilever pointer.int (*B2) [10]=new int[10][10]; Note that the B2 here points to the first address of a two-dimensional array of int.Note: Here, B2 is equivalent to a two-dimensional array name, but does not i
Two-dimensional arrays and pointers pointing to pointersA problem raised by a question, first of all know [] the priority is higher than *, the title:Char **p,a[6][8]; Q. Does p=a cause problems with the program at a later time? Why?Directly with the program description:#include void Main (){ Char **p,a[6][8]; p = A; printf ("\ n");}Compile, and then you will find that the error is incorrect 1: "=": "Cannot convert from" char [6][8] "to" char
Conceptvoid pointer data pointer
void Pointer
Basic concepts of void pointers
void means "no type", and void pointer is "No type pointer", and a void pointer can point to any type of data.
so void pointers are generally referred to as universal pointers or generic pointers, or universal
Original works, reprint please indicate the source http://blog.csdn.net/yming0221/article/details/7220688 C language more see C language use attention (i) C language use notice (b) C language use attention (iii)
Second-level pointers are also called double pointers. There is no reference in the C language, so you must use a level two pointer when you try to change the value of a pointer. Reference types can
I. Memory Allocation for pointers and heap
A pointer is a type of pointer. In theory, it contains the addresses of other variables, so it is also called address variable in some books. Since the pointer is of a type and has a size, the pointer size is 4 bytes in size on the Dana server or on a common PC, and only the address of a variable is stored in it. No matter what type of pointer, char *, int *, INT (*), string *, float *, it indicates the type
.main function in any case in the first place 2. No matter what, function to write declaration and implementation declaration at the top, #include the following implementation is written after the main function 3. Declaration and Implementation consistency the operation between pointers why is there no addition between the two pointer variables? and multiplication and division 1. If you add, you may cross the line after the addition. The address boun
This article and we share the main is the C language null pointer null and void pointers related content, together look at it, hope to learn C language to help you.empty pointer nullA pointer variable can point to any piece of memory on the computer, regardless of whether the memory is not assigned, or if it has permission to use it, as long as the address is given to it, it can point to the,c language there is no mechanism to ensure that the pointing
The C language pointer is quite flexible, but it is also quite easy to make mistakes. Many C-language beginners, even the C-language veteran, are apt to stumble under the C-language pointer. But there is no denying that the position of the pointer in the C language is extremely important, perhaps to a radical point: the C program without pointers is not a real C program.
But the C + + pointer often gives me a feeling of being shackled. C + + has more
5. a deep understanding of C pointers: 5. pointers and stringsBasic Concepts
Strings can be allocated to different areas of memory. Pointers are usually used to support string operations. A string is a sequence of characters ending with the ASCII character NUL. The ASCII character NUL is \ 0. Strings are usually stored in arrays or memory allocated from the stack
of type int.Method Three, create a one-dimensional array, the elements in the array are pointers to other things, also known as Level two pointers. The function is an int fun (int **arr), which dynamically handles data that is not the same length for each column of the row.Note: You can do this only if you change the two-dimensional array to a pointer array that points to a vector. For example, the followi
Remember the beginning of work, a master told me that longjmp and setjmp play is not familiar, do not call themselves C language master. At that time I was doubtful, in order to let oneself to master direction, still spent a little time to learn longjmp and setjmp usage. It was later understood that it was not simply jumping and jumping, but rather a high-level exception-handling mechanism, which was indeed useful in some cases.In fact, longjmp and setjmp are not familiar with the C language mas
The concept of pointersThe pointer is the address that can be used to find the specified data.The pointer is the address, so when used, it is often simple to say that the pointer variable is a pointerA pointer variable is a variable that stores an addressint *p1;//applies a variable that opens up a piece of memory in memory, storing the dataOpens up 8 bytes, and the pointer is 8 bytes under the MacUsing pointers, you should actually say, using pointer
pointer is represented by (void *) and is therefore also known as a void pointer.int n=3, *p;void *GP;GP = n;p= (int *) GP1;The wild pointer, which is a pointer to an area of unavailable memory. The usual manipulation of such pointers will cause unpredictable errors in the program.The "Wild pointer" is not a null pointer, it is a pointer to "junk" memory. It is generally not wrong to use a null pointer because it is easy to judge with an if statement
Chapter 4 Structure and pointer
This chapter is the linked list. A single-chain table first, followed by a two-way linked list.
Summary:
A single-chain table is a data structure that uses pointers to store values. Each node in the linked list contains a field to point to the next node in the linked list.
There is an independent root pointer pointing to the 1st nodes of the linked list. A single-chain table can only be traversed in one direction.
How
Let's talk about how to study pointers and how to overcome the difficulties brought by pointers.
After writing a pointer blog, I always feel that I have not completely told you all my ideas.
First, the C ++ pointer is difficult for all programmers, and it is normal to avoid or make frequent mistakes. Your teacher will also make frequent mistakes.
Second, pointe
The return value of a function pointer is an array of pointers, where the return value of an int function pointer is an array of pointers, and an int pointer is placed in the array.#include #include voidFunintA) {printf ("fun:%d\ n", a);}voidFUN1 (void(*f) (int),intA) {f (a);}intGunintA) {printf ("gun:%d\ n", a);}intGUN1 (intAint(*f) (int) {printf ("gun1:%d\ n", a);}int(*hun (inta)) []{int(*p) [3] = (int(*)
The concept of pointers
The pointer is the address that can be used to find the specified data
Pointers are addresses, so when used, it's often easy to say pointer variables are pointers
A pointer variable is a variable that stores an address
int *p1;//applies a variable that opens up a chunk of memory in memory and stores the data
Opens up 8 bytes, and the
const* P2;/* Defines a const pointer (must be initialized because the value of the pointer itself cannot be changed) * *int* Const p3=a;/* The pointer itself and the content it points to can not be changed, so also have to initialize the * *Const int* Const p4=a;int const* Const p5=b;p1=p2=a; That's right*p1=*p2=8; Incorrect (the pointer points to content cannot be modified)*p3=5; That's rightP3=P1; Incorrect (the value of the pointer itself cannot be changed)p4=p5;//is incorrect (the pointer i
The nature of the pointer array and the pointer function is unchanged, or arrays and functions. and the array pointer and function pointer, which is the indication that this is the pointer, points to the types of arrays and functions respectively.
One
Array of pointers: the array that is used to store pointers, that is, the array elements are pointers
Char Const
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.