Review of knowledge points – Review and sort out the knowledge points of C language to see if you have fully mastered them

Time:2021-12-25

Some time ago, I shared some essential knowledge points about C language. Interested friends can check my past articles, or pay attention to the C language advanced path of the official account, check the next article, or search keywords, “programming white foundation”, you can check the relevant chapters.

After talking about the knowledge points of C language, we can also sort out and summarize here. You can check the directory and recall the knowledge points. If there are no problems, you can enter the next stage.

 

The sharing order is as follows:

History of C language

Basic data type

Constant and Variable

expression

operator

Sequential structure

Cyclic structure

array

function

Pointer

structural morphology

file

If you see the summary of the above knowledge points, you still have a little vague about the previous knowledge, you can check my previous articles~

Digression

Here are some problems that many novices will encounter in learning. I hope it can solve your doubts.

Are there any good C language books recommended?

You can also look at previous articles. In fact, many recommendations have been made for books. Those books are still fixed. I won’t repeat them here.

Learning knowledge is to see what to do if you don’t understand grammar.

You should understand one thing, the new knowledge you learn. If you really don’t understand why, remember him. Don’t waste too much time on it, because these knowledge has not been overthrown after decades of baptism, which shows that it has the value of existence, but your knowledge reserve is not enough for you to understand him. For example, I have met people who don’t understand the difference between assignment and congruence and have their own ideas. In fact, this is the same as the fixed collocation in English. You don’t have to think about why it is like this, the definition is like this, just remember it.

Whether it is the real world or the computer world, all the existing knowledge is artificially defined, and then after everyone’s deliberation, we feel that this thing is correct, and then it will be widely used. If one day you find that there is a problem with the definition of a certain knowledge in the real world, you can also put it forward. After the trial in the academic circles, if you think you are correct, then you will be recorded in history, and the things you put forward will be widely used by everyone.

 

Then, for the above knowledge points:

1. Basic knowledge

The so-called basic knowledge is some prerequisite knowledge that we must have to learn C language and even enter the programming industry.

If you don’t know some computer knowledge and you don’t have a compiler installed on your computer (the compiler is the place where you type code), you’d better not learn it and waste time, because programming grows up in actually writing code, not reading books.

 

So, how much basic knowledge is needed?

In fact, at the beginning, it was not a lot. It was all about common sense. Students who had been exposed to computers at the age of 18 or 19 should have some knowledge.

First, why learn C language.

C language is a necessary language for people in the IT industry. C language can not be used, but it can not be used. Of course, its advantages can be found in the article.

 

Secondly, the components of the computer.

I have to learn programming. I can’t even know the most basic computer composition.

Finally, the compiler installation.

It’s not just C language that needs to install a compiler. As long as you contact programming, no matter what language you learn, the first step is to install the compiler and output “Hello world!”.

2. Sequential programming

Sequential programming, to put it bluntly, is the process of writing code, which is very similar to the process of people doing one thing. People deal with a thing basically from the front to the back, and the code is the same. The code written in the front will be executed first, and the code behind will be executed later.

People make jokes when they do things in the wrong order; If there is a problem with the sequence of program execution, there will be a word we often say – bug.

Know where the program should be written.

When most programming languages are written, there will be a specified program start position “main”, that is, when the compiler executes the code, it will look for the code in main to execute. So we’re going to write our code in this.

Some prerequisites for the operation of C program.

The previous question said that the code should be written in main, so where should main be placed?

Understand the idea of programming.

In other words, writing code is actually the same as people doing one thing, but the purpose of writing code is to let the program help us do the same thing cycle by cycle.

3. Data type

In the real world, there are integer, decimal, fraction, complex number and other data types; The reason why these data types exist is not out of thin air. They are defined by some great mathematicians. The reason why they can be used all over the world for so long and will continue to be used is because they are in line with people’s cognition and practical.

The programming world can also be regarded as a small world, so there should be some data types in this small world, but the main body of the data type in the program is not people, but computers. Due to the limitation of computer storage mode and storage length, C language will define some practical and recognized data types for C language programming. This is why data types are generated.

4. Standard input and output

After the above study, you should know that the storage form of any data in the computer is binary 0 / 1 string, so when we want to output a text, we can’t output these 0 / 1 strings directly. This is the function of formatting. It can convert the 0 / 1 string into the data form you want according to the formatting method you choose.

5. Binary conversion

The decimal system is used in the real world, and the binary system is used in the computer, so it is necessary to learn the conversion between decimal system and binary system.

In the real world, if we want to describe a large number, we know to describe it in larger units. The same is true for computers. It is a little cumbersome to describe a data directly in binary, so it will produce some larger units, such as octal and hexadecimal.

Take a chestnut: in the real world, 10000 can be described as 100000. The binary data 00110001 in the computer is represented as 31 in hexadecimal, which is indeed much simpler.

6. Select structure

Selection structure is to select the data that meets the needs from a large number of data for the next operation.

Take a chestnut: select students whose math scores are more than 60 from the transcripts of the whole class. This process is what needs to be done to select the structure.

7. Circulation structure

There are many things in daily life that are repeated and repeated. This is also the case in programming. Some code may be repeatedly executed thousands of times. At this time, you can use the loop structure to replace some repeatedly executed code. You only need to keep a copy of the code and make the code execute repeatedly.

Nested loop: it is to put a loop inside the loop structure.

The differences and characteristics of the three loops: you should know that the for loop can specify the number of loops; The number of while cycles is uncertain; do… While will cycle once before entering the judgment condition.

Interruption of cycle: there are two ways to end the cycle. The first is to stop the cycle when the cycle times or cycle conditions are not met; Another is to force the cycle to stop.

There are two ways to force a stop: break and continue.

8. Array

With in-depth study, you will find that there are more and more data, some of which have the same format and express the same meaning. If these data can be stored together and named uniformly, it will be very convenient. So the concept of array came into being.

An array is a set of data, and the data set is sequential. The data types of all data in the set are the same.

9. Function

With the in-depth study, it is found that more and more code is put in main, and many codes are written repeatedly, resulting in more and more bloated main; So we plan to extract the code with the same function from main, which is called a function. Give this function a name, and then only call the function name when using it.

10. Pointer

Pointer is the essence of C language. Pointer can provide users with the function of directly operating memory address. Other languages are shielding this function. It is because of the existence of pointer that C language becomes powerful. At the same time, because of the existence of pointer, C language becomes unsafe.

Take a chestnut: there is a variable int a = 3; The usual way to modify data is to use variable A. when using a pointer, you can directly find the address of this 3 in the computer memory and modify it directly without using variable a.

The working principle of the pointer and the principle of memory: the pointer is the address, and the address is the space where the actual data is stored in the memory.

Pointer, pointer variable relationship: pointer is an address, and pointer variable is just a variable pointing to pointer.

I have divided this part into two parts

11. Structure

After contacting more and more requirements, you will find that simple data types such as int, float, char, etc. are not enough, so you need to use the structure to customize some data types.

Take a chestnut: we want to customize a student data type, but there is no such data type in C language. What should we do? We can organize the basic data types int, char, array, etc. through the structure to form a user-defined data type, and give it a name called student. This is a custom data type.

12. Documentation

Finally, all programming languages can operate files, because all data after the program runs is temporary. If it is not stored in the file or database, the data will disappear after the program runs. If you don’t learn the database at present, store the data in the file. Here, the knowledge point is released by the video number, and official account will help you.

Well, this is a summary and summary of the C language knowledge in the past. Detailed information can be viewed in the official account.

 

Finally, if you encounter difficulties in self-study, you want to find oneC/C++Learning environment,You can join usC++Learning circle, click me to join, it will save a lot of time and reduce many problems encountered in learning.

 

Recommended Today

Nsmutablestring do not use copy

doubt: We all knowcopyGenerally used to modifyOn immutable objects with corresponding variable typesFor exampleNSString,NSArrayandNSDictionary。 So why not recommend itcopyTo modifyNSMutableStringandNSMutableArrayBut withstrongAnd? Test: I haven’t paid much attention to this problem at ordinary times, so I’ll test it. 1、 First test why nsstring uses copy First define two string attributes, onestrongOnecopy: Decorate with strong @property (nonatomic, […]