C language learning - first understanding of C language

1. Program structure
In the previous section, we have come into contact with the first applet of the C language and have a preliminary understanding of the C language. Next, we will look at the specific structure of the C program.
Simply put, a C program consists of several header files and functions.
Recalling the example written in the previous section, here is an analysis of the example:
#include <stdio.h> is a preprocessing command, its function is to inform the C language compilation system to do some preprocessing work before compiling the C program formally. (We will talk about preprocessing later in the course)
A function is a small unit that implements code logic.
Note: In the latest C standard, the type before the main function is int instead of void

2. Essential main function
A C program has one and only one main function, the main function.
The C program is to execute the code in the main function. It can also be said that the main function is the only entry in the C language .
This principle is like each elevator has only one door. If you want to take the elevator, you must enter through this door; and the int in front of main is the type of the main function, such as what material the elevator is made of.
printf() is a format output function . Remember that its function is to output the specified information on the screen , which will be explained in detail later. E.g:
return is the return value of the function, and the returned value is different depending on the type of the function.
\n is an escape character, which can be viewed in WIKI.
Note: The C program must be executed from the main function.

3. Program Explanation - Comments
Comments are set up so that others can understand the programs you wrote, and so that you can still understand the programs you have written years later. Comments are written for programmers, not computers. Therefore, the content of the comments will be automatically ignored by the C language compiler when compiling.
There are two methods of commenting in C language:
       Multi-line comments: /* Comment content*/ 
       Single line comment: //Comment a line
The following is an example of using multi-line and single-line comments:



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325750631&siteId=291194637