This article on learning pointers is for beginners. This is the purpose of my post. I am also a beginner (I have emphasized this countless times). I use my understanding to write down things that beginners find difficult to understand in simple language. Since I did not learn Chinese well in elementary school, I may not be able to achieve this goal even if I try my best. Just do your best. Pointers are the difficulty and focus of C and C++. I am only proficient in Basic under DOS. The other various features of C language have similar things in Basic. Only pointers are not available in Baisc. Pointers are the soul of C. I don\'t want to repeat what is clearly stated in most books. I just write down what is not clearly stated or not stated in the books I have read, but I think I understand it a little bit. My purpose is: 1. By writing these things, I can clarify the vague knowledge about C in my head. 2. Give beginners some tips. 3. Earn some experience points. (Because posting these things is not suspected of spamming) Chapter 1. The concept of pointers A pointer is a special variable, and the value stored in it is interpreted as an address in memory. To understand a pointer, you need to understand four aspects of a pointer: the type of the pointer, the type the pointer points to, the value of the pointer or the memory area the pointer points to, and the memory area occupied by the pointer itself. Let\'s explain each of these separately. First, declare a few pointers as examples: Example 1: (1) int *ptr; (2) char *ptr; (3) int **ptr; (4) int (*ptr)[3]; (5) int *(*ptr)[4]; If you don\'t understand the latter few examples, please refer to the article I posted some time ago. 1. Pointer type. From a grammatical point of view, you only need to remove the pointer name in the pointer declaration statement, and the remaining part is the type of the pointer. This is the type of the pointer itself. Let\'s look at the types of the pointers in Example 1: (1) int *ptr; // pointer type is int * (2) char *ptr; // pointer type is char * (3) int **ptr; // pointer type is int ** (4) int (*ptr)[3]; // pointer type is int(*)[3] (5) int...
You Might Like
Recommended ContentMore
Open source project More
Popular Components
Searched by Users
Just Take a LookMore
Trending Downloads
Trending ArticlesMore