Learn C language easily (requires tutorial)

Today, I will share with you my own C language learning process and share with you. Well, because my own level is limited, it is inevitable that mistakes will occur. I hope that everyone can point out after seeing them so that everyone can make progress together.

First of all, let me talk about why you should learn c language:

The first C language is a basic language and the basis for learning other languages. It is said that the underlying java and .Net are written in C language, and the windows and linux kernels are also written in C language.

The second C language is powerful. Because C has a powerful tool for pointers, so having higher permissions allows us to use more functions, like java can not operate other programs, can not be used to write plug-ins, write some hacking tools or something.

The third C language programmer has a higher salary.

The following describes the basic requirements of the school C:

Learning C language does not require much English. You only need to remember 32 keywords. 10 days a day, it will be finished in 3 days.

Auto local variable (automatic storage)

Break unconditionally exits the innermost loop of the program

Selection in case switch statement

Char single byte integer data

Const defines constant values ​​that cannot be changed

Continue interrupts this loop and goes to the next loop

Default selection in the default switch statement

Do is used to construct a do.....while loop statement

Double defines double precision floating point data

Else constitutes if.....else selection program structure

The enum enumeration extern describes global variables in other program modules.

Float defines single-precision floating-point data

For constitutes a for loop statement

Goto constitutes goto transfer structure

If constitutes if....else selection structure

Int basic integer data

Long long integer data

Registered variables inside registerCPU

Return is used to return the return value of the function

Short short integer data

Signed number

Sizoef evaluates the number of bytes occupied by an expression or data type

Static defines static variables

Struct defines structure type data

Switch constitutes the switch selection structure

Typedef redefines data type

Union joint type data

Unsigned defines unsigned data

Void defines untyped data

Volatile This variable can be implicitly changed during execution in the program.

While is used to form a do...while or while loop structure

Then you remember that 9 control structures are OK.

Goto statement: unconditional turn;

If statement: judgment statement;

While loop statement;

Do-while statement: first execute the loop body, then determine whether the loop condition is true. Then continue the loop;

For statement: loop, can replace the while statement; only the usage is different;

The break statement jumps out of the loop of this layer; (only jumps out of the loop containing this statement)

Continue statement: continue (usually placed in the loop statement, not executing the statement below it, jump directly to the judgment statement example:

For the statement, jump directly to the second semicolon,

The while statement, jump directly to the brackets of while();

Switch statement: multi-phase selection;

Return statement: return;

How good is mathematics?

No, as long as you graduate from the second grade, you will use +plus-minus*multiply/divide% to get the balance.

Formally enter C language learning

As the saying goes, learning C does not learn hello blueshell1949, learning C is also white. So our first and learning thing is also a simple hello program.

I am going to talk about hello blueshell1949 today. I am sure to bring everyone to play a new idea, in order to live up to everyone's reading skills, let's take a look at it slowly:

The first one, let's play with vs2013 first, first look at one

This is our first hello blueshell1949. How amazing it is. Get rid of the black window.

Below we post the code.

Int main()

{

MessageBoxA(0, "HELLO blueshell1949", "First C", 0);

Return 0;

}

Let's see how it is implemented. Here we use a windows library, which is the window system function. In the first lesson, we don't need to know what is inside, how to use it, just as I wrote it. We use the messageboxA function, the function is to pop up a system dialog box, the first parameter is 0 by the system, the second parameter is the text content, the third parameter is the title, the fourth parameter, oh, I will give Let me demonstrate it.

I changed a parameter. Did you find any difference?

Is the difference in the options of the pop-up dialog box. You can also change it yourself to see how many changes can be made! Hey.

Below we are on the basis of this, we add a bit of stuff, let us first look at the effect:

Is it a hello blueshell1949 in the upper left corner? How did we do it?

Let's look at the code

#include

#include

Int main()

{

Printf("Hello blueshell1949");

MessageBoxA(0, "HELLO blueshell1949", "First C", 1);

Return 0;

}

What is the difference between us and the above code?

Is it just a line of printf ("hello blueshell1949");

The function of the Printf() function is to print it out.

Teach everyone a little trick. Win+R Then enter notepad to open Notepad.

Ok, let's enter the following code in Notepad:

We save as 1.c

Then open

We enter the path where we started 1.c

We enter cl 1.c

We can get the compiled file. Equivalent to the compilation run in ide. We enter 1.exe and we can see the effect

We just opened the notebook manually, so trouble, can we write a program to open the notebook automatically?

The answer is yes.

Let's try:

We enter the following code. We are coming to cl.

We can get the following results

We can see that we output blueshell1949 is really humorous, I want to give him a monkey. And opened a notepad.

In our comparison, what is the difference between us and the above code. Two more lines of code

#include

System("notepad");

I am explaining the concept here, stdlib is the standard library for C language. System is a function that can call other functions. For example, notepad is a notepad, and calc is a calculator. So total.

Here we can only do a lot of things by learning two or three functions. So, do you still have difficulty getting started with C?

Uv Curving Glass

Uv Curving Glass,Tempered Glass Screen Protector,Film Cutting Machine,Uv Curing Protector Screen

Shenzhen TUOLI Electronic Technology Co., Ltd. , https://www.hydrogelprotectors.com