Really it is not hard to

Is C language difficult? This question is relative, for students who find the right way to learn C language must feel very simple; But for some students, there is no view of the overall situation will be mistaken for the entry to learn a huge amount of knowledge, learn to learn to begin to understand, because of psychological quirk, feel the content is huge, then really have been unable to understand.

But is there really much basic content in C? The answer is: not much. Look at the figure below. C can be divided into 9 blocks, or 9 main points of knowledge. Only nine? That’s right, nine. These are printf outputs, variables, scanf inputs, arrays, logical judgments, loops, custom functions, Pointers, and structs.

Next, I will explain a brief summary of each knowledge point to help learners progress together.

The following will explain the knowledge point when there is a corresponding knowledge point of the tutorial link, click in you can see the article tutorial, all free, no routine ~

Let’s start with a complete catalog of tutorials

directory

First: (1) from learning mistakes second: (2) C language is not so difficult simple development lead you to understand the process third: (3) easy to understand the first C language program fourth: (4) basic data types and variables fifth: (5) C language variables, constants and operations sixth: (9) The basic array is not so simple. (9) THE TWO-DIMENSIONAL array and loop nesting of C language. (10) The pointer of C language is originally like this. (11) C language custom function is really very simple twelfth :(12) the original structure is such a thing thirteenth :(13) socket server written

C language novice 100 error solutions

recommended

Welcome everyone to pay attention to the public account, the public account every 1024 and 1024 times will be lucky draw a mechanical keyboard + 2 IT books oh ~

Learning goals

1. It’s not hard to know C

A, printf

When you learn C, the first program is usually HelloWorld; HelloWorld is basically a program that displays HelloWorld text while the program is running; The code you use is printf. This is the first step of the program, and there is not too much content, mainly to understand the use of software, and try to write the first program.

(3) Easily understand the first C language program

Second, the variable

The variables section mainly introduces how to use variables and tells you that there are many types of variables. In fact, a variable refers to a container that can store values. It’s very easy to understand, for example, the cup you use in your life, the cup is for water, or some liquid; The value of the container is water, and the container is the cup. Then I can also use the drawer to hold the book, the book is the value, the drawer is the container.

In programming, too, different containers correspond to different drop values; In C, there are several types that specify the use of specified containers for storage. It can also be stored differently, as if you had a paper cup with red carbon in it. High temperatures will melt the cup. Unless you wanted it to be that way.

So variables are a very simple thing. In this section on variables, you’ll also learn about the output of variables. The output value is, we are displaying the contents of the container while the program is running; It’s like you have a bucket of your fishing catch, and you show it to everyone.

Another key concept of variables is variable. What is variable? Variable is the value that you can put something new in your container after you pour it out; I can put more water in my cup when I finish drinking it. But constants are different. Once a constant has its value stored, it cannot be changed. It is wrapped and sealed. You can only see what’s inside and show it to everyone, but you can’t take it out and put anything else in it.

Variable tutorial reference: (4) basic data types and variables of the language (5) C language variables, constants and operations

Third, the scanf

Scanf is mainly used to receive input from users. What is receiving user input? After we run the program, for example, we need to enter a password to start the program; I need to enter a value, and the program waits for me to enter a value; After the input, the program receives the value and determines whether it is correct. To do this, you need to use scanf in a C program.

Scanf does several things, but the most important thing is to know the address of a variable. Normally, when we enter a value, we need a variable to receive it; To input a value, we need a variable to store the value. But to do that we need to know the address of this variable, and once we get that address we’re going to store that value in this variable. Each variable has an address in memory, like where you live, and a tag, and you give that tag to Scanf to store the value in that variable.

This knowledge point is not listed here because it is integrated into other knowledge points :(1) escape from learning mistakes

Four, arrays,

Arrays are about understanding how array structures are stored. An array is a container for storing a bunch of values. Unlike a single variable, an array can hold multiple values. For example, we can use arrays if we need to store multiple values of the same kind of data. Arrays are stored like a drawer, with each drawer holding a value, such as row 1, row 1, row 1, row 2.

A two-dimensional array is actually the same as a normal array, except it has a second row, a third row, and so on. So if you can understand a drawer, you can understand an array.

The index refers to the number, the number of the row, the number refers to a quantifier to the position of the mark; Accessing an array just means going through those drawers and putting something back in, that’s all.

Array tutorial reference: (eight) understanding the basic array is not so simple (nine) C language two-dimensional array and loop nesting

5. Logical judgment

In fact, logical judgment is to judge some values, for example, as just said, the program needs to input a value every time it is opened, determine whether this value is the password to open, if the input error to exit the program.

Then you need to use if or switch. If and switch are the same function, understand both, just use a different format. For example, if we open the program and enter 1234, the password is 123456; The input value is stored in A container, and that container is given A name, or A label, called A; So we just have to figure out if A is equal to 123456. That’s where logical judgment comes in.

Logical judgment can also be “nesting doll”, that is, to judge whether it is correct and then judge, but also to judge multiple conditions at the same time. For example, the current password knows that it can be split by 2 and is correct if there is no remainder, but it cannot be equal to 2. At this point, you need to use the logical judgment operator, just put the content you want to judge on the left and right sides of the logical judgment, and you are done.

(six) easy to understand the logic of C language operations

Six, circulation

Loops are designed to run some code repeatedly. The main logic used is, give the loop how many times you want to loop, give the code for the loop, and finally give a control variable for the loop; The function of the control variable of the cycle is as the name implies, used to control the number of cycles; We set up a container with the number 0 in it, incrementing it with each loop; For example, the number in the container is 0 at the beginning, and then we add 1 to it once, which is the value in the container, and each time we add 1, we increase each time; In this case, the number of times we give is 10. Each cycle we can control the number of cycles as long as we determine whether the control variable of the cycle is greater than 10.

For loops, while loops, and do… While loops are used the same way, with loop variables controlling the number of loops. Loops can be nested. For example, loop nesting means that there is another loop inside a loop, and each loop outside the loop is repeated once, and the loop inside the loop is repeated a specified number of times.

Using loops is especially handy when we need to repeatedly set the values stored in our array. For example, if you need to place a value in each drawer of a large rule, use a loop to solve the problem in minutes.

Cycle tutorial reference :(seven) C language cycle minute start

Custom functions

Custom functions mean that you can create your own toolkit. For example, washing machine is a functional tool, it is used to wash clothes, every time you use the washing machine to throw clothes into it can automatically help you to complete the task. The same goes for custom functions, which can be used directly after a function is implemented.

Washing machine function is to wash clothes, but must have clothes to wash, clothes is the parameter; If the washing machine gives you clean clothes after washing them, then clean clothes are the return value; Is the result of the whole function.

Custom function reference: C language custom function is really simple

Eight, pointer

A pointer is a proxy that allows you to access variables or operate directly on them. You are their master. But when you use a pointer you have to know the address of the thing you’re manipulating, or where to operate from; Multiple Pointers are when your general agent partners with another person, and you can operate that other person’s agent.

So why are Pointers dangerous? That’s because your agent keeps the data of the previous owner, and if you just ask him to manipulate something, he will take the data of the previous owner and manipulate it, so that you manipulate something that doesn’t belong to you, and that’s a warning. So remember to throw away the previous owner’s data when using the pointer tool, and ask it to throw away all data when you’re done using the pointer tool.

(10) C language pointer is originally like this

9. Structure

A structure can be thought of as a type of combination. For example, if you use variables to store a person’s name and age, you need to create two new variables. For example, if you want to store a person’s name and age, you need to create two more variables. It’s too much trouble. A structure is like a big container. Unlike an array, a structure can store its own values in a variable. An array is a variable, and a structure contains other variables. We create a new structure called “person”, and we create two variables inside the person structure, one is the name, one is the age, then we just need to create the structure, we can directly have two variables, easy and convenient.

The original structure is like this

conclusion

Once you understand the concepts, it’s easy to learn the grammar rules.