What is included in the C language, which parts are important, and which parts need to be understood?

Recently completed the chat room project, C language based learning stage is also considered to have come to an end, but I'm still just an introduction to the C language, like a tool, I just now understand, will use it, but did not achieve For example, if the arm is to be used as a weapon, we will need to further study C language in the future. Today I will talk about my personal understanding of the C language, my own understanding, and if I have any mistakes, I would like to point out that I am not very grateful. .

The first is the context of the C language. What is included in the C language, which parts are important, and which parts need to be understood? This is the two questions I often ask myself.

First of all, what are the things in C language? The things in C language are not too many:

1, some of the most basic data types and their memory size, there are some basic computer knowledge (such as conversion). These things are easier after having a certain understanding of the C language.

2, three kinds of logic (order, selection and loop)

Sequential statements are statements that are not judged from top to bottom and are one step at a time.

The select statement is the if and switch statements. In a particular case, the use of the switch statement makes the program look simple and clear, especially when there are many options. Most of the time the if statement is used a bit more.

The loop statements are while, do...while, and for statements. These three do...while I don't use too many and I don't comment. There are many occasions for the while statement and the for statement. Let me talk about a few points:

a. In the multi-layered cycle, keep the longest cycle as far as possible and save the cpu resources.

b, can not modify the cycle variables in the circulation body to prevent the cycle from losing control.

c. The loop is as short as possible. Too many lines of loop code can greatly affect reading. Workaround: Use subfunctions to handle

d. The loop nesting is controlled within 3 layers, more than three layers, and the difficulty of understanding the code is greatly increased.

The control expression of the e, for statement can not contain any floating-point type of object

There are break and continue statements. Frequently, someone will ask me what the two keywords are. Break is to jump out of the closest loop (the switch is out of the switch, not out of the loop), and continue is the same.

3, arrays and pointers

Array I divided it into two: ordinary arrays and strings, where the operation of the string is the most critical step of the C language assessment, because it involves arrays and pointers, the string operation of the very cattle people, they The understanding of pointers must be deep.

Ordinary array:

The content of a one-dimensional array is not too many, but the requirements for the algorithm are relatively high, the most basic is that it must bubble and select the sort, these two algorithms are the most basic, but also the most used in the sort (if more If you are interested in another algorithm, then you can do more research on the algorithm. (I haven't had time to study the algorithm and I don't know much about it). For two-dimensional arrays, to understand the memory allocation and the storage order of elements, input and output will be performed on two-dimensional arrays. Others are algorithms, and they will be slowly studied later.

String:

This part of the string, because the C language string operation is not as easy as c++, so the pointer and array next piece of work. The simplest is to use string.h in the strlen, strcmp, strcpy, strcat, and strncmp functions.

pointer:

When the teacher talked about the pointer, he said, if you learn the pointer, you will have 70% of the C language. I was still a bit skeptical at the beginning. Now I very much agree with this sentence. Pointer is the essence of C language, C language is a soft and hard-going language, in the final analysis is the knowledge of this pointer, he can directly manipulate the bottom. Regarding the pointer, I was most impressed by that example. *p imagined p as the number of the Xiaoming family, and * was a master key. *p represented the value of Xiaoming himself. You could give Xiaoming's address to others. Other people can see Xiaoming himself by holding *(Master Key) and p(Xiao Ming House). You can operate Xiaoming himself. This example gave me a very deep impression at that time. After that, I felt that my understanding of pointers was clearly clear. I was very grateful to my C language enlightenment teacher. With his leadership, I could have a deeper understanding of C language.

4, function

The function I feel is an extension of the main function, but it is repeatable, you can write some complicated steps inside a function, so that the main function does not appear too bloated. The most important function is its format, return value + function name + (parameter) + function body, one of which is easy to overlook is that when the parameter is a pointer, at the beginning of the function, the entry parameters The check is to judge whether the pointer is empty or it is easy to have a segmentation error. Another is that if a function is below the main function, it's best to make a statement. Although the current compiler has omitted this step for us, we still have to develop good habits. After all, if you give an old version The compiler will complain. Compiler optimization is not the reason we are lazy. However, we can also write the function above the main function so that we do not need to consider this problem. In this part of the function, I still have many deficiencies in some places, such as recursive functions and callback functions, recursive functions involve some algorithms, I still do not know enough about the algorithm, so. . . There is not much contact with the callback function, so far it has come into contact with a SQLite3_exec function in the sqlite3 function as the third parameter of the function name.

5, keywords

The scope of the static global variable is limited to the source file, can not be used by other files of the source file local variables are limited to a specific function, the scope is not released, the function scope is still limited to the source file after the function is ended, can not be the source file other The file use function name is not visible in other files const This keyword actually only needs to remember a poem on the line, "the first time to get the moon near the water," the closest to the const that can not be changed.

The extern keyword is generally used in the .h header file to declare a function, not in this file.

Struct structure, containing a variety of data types of variables, often used in data structures, such as: linked lists, stacks, queues, etc.

The enum enumeration is similar to the define function. The enumeration and the macro are very similar: the macro replaces the name with the corresponding value in the preprocessing phase. The enumeration replaces the name with the corresponding value in the compiling phase.

The union is similar to the structure of the structure, but the members of the structure occupy different memory and have no influence on each other. All members of the union occupy the same memory, and modifying one member affects all other members. Used to test the size of the system side.

To this end, the content of the C language is almost the same, in addition to some other bits and pieces of knowledge. But I learned LinuxC, so I also learned the management of Linux processes and threads, as well as the operation of files and the programming of Linux networks. The programming of Linux network --- The server that sets up tcp agreement is actually the tcp_net_socket.c in the first two articles of these few routines have been put together already. The file operation, Linux system provides a file descriptor mechanism, open after the file descriptor read and write, and C language is the fopen function, returns a pointer, the principle is similar, but the C language provides the fopen series function Can cross-platform operation. In fact, threads and processes have little content (possibly because of the shallowness of learning), and too complex content does not come into contact. One thing to mention in the thread is that of synchronization and mutual exclusion. In fact, it is also very easy to understand. For example, a door stipulates that only one person can enter a person. At this time, there are 10 people. If there is no order, if there is no order, it is mutual exclusion. If they line up according to certain rules, it is synchronized. Synchronization is a special kind of mutual exclusion.

Think about it. If you miss something important, I hope readers can prompt me for improvement.

Moving head beam light

Well and hight quality control
New design products
Customers design and Logo are welcomed
Quickily delivery
Competitive prices
Fit for gifts and premiums
sample can be available
OEM acceptable
Years of exporting experience as professional stage lighting manufacturer:
Senior R&D technical staff with 7 years experience in stage lighting industry;
Strict quality control in producing to maintain reliable quality;
Provide cost-effective products, wholesale price;
Professional sales team to provide perfect service.



Our company have 13 years experience of LED Display and Stage Lights , our company mainly produce Indoor Rental LED Display, Outdoor Rental LED Display, Transparent LED Display,Indoor Fixed Indoor LED Display, Outdoor Fixed LED Display, Poster LED Display , Dance LED Display ... In additional, we also produce stage lights, such as beam lights Series, moving head lights Series, LED Par Light Series and son on...

Moving Head Light Series,Beam Moving Heads Light,Beam Moving Light,Moving Head Light Beam

Guangzhou Chengwen Photoelectric Technology co.,ltd , https://www.cwleddisplay.com