- Learn C language from the first C language program
- Learn about Keywords
- Understanding functions
- Comments
- C-Language execution process
- Identifier
- The hard and difficult point of C language learning
Learn C language from the first C language program
is a "Hello, world!" displayed on the console C-Language source code.
Where #include <Stdio.h> is a preprocessing file. Usually the program needs to process some content before compiling, which is called "Precompiled Processing Command", which usually begins with the # number and ends without a semicolon, so it is not a C-language program statement.
The precompiled Processing command here (#include <Stdio.h>) is called a file containing command, and its role is to compile some information file Stdio.h files that are included in the system Custom function printf () before compiling the program. Files ending with ". h" are called header files.
When using input and output functions in a standard library, the compilation system asks the program to provide information about the input and output functions, #include <stdio.h> is used to provide this information, Stdio.h is a file name provided by the C compiler system, and Stdio is the abbreviation for "standard input & Output", which is information about standards input and output. When using an input-output function in a system-supplied standard library of functions, write a line at the beginning of the program: #include "stdio.h" or #include<stdio.h>, so that the library function can be called. The two main lies in the search efficiency differences, #include <stdio.h> generally include system files, it is to find the first from the system directory lookup start; #include "stdio.h" is generally used to include the project file, which is to find the first search from the project directory. In writing C, commonly used in the printf () and scanf () functions, they are the two standard input and output functions in stdio.h, so it is important to include #include<stdio.h> in the header file if the two functions are to be used in a programming statement. Learn about Keywords
Keywords are words that have been used by the C language itself and cannot be used for other purposes. Therefore, identifiers with the same name as the keyword cannot be used when user-defined variables, functions, and so on.
There are 32 keywords in the C language, each of which is:
Data type Keywords
A. Basic data Type (5)
void declares a function with no return value or no argument, declares an untyped pointer, and explicitly discards the result of the operation
Char character type data, which belongs to a kind of shaping data
int shaping data, usually the machine word length specified by the compiler
Float single precision floating point data type, which is a kind of floating point data
Double-precision floating-point data type, which is a kind of floating-point data
B. Type modifier keywords (4)
short modifier int, shorter integer data, can omit the modified int
long modifier int, longer integer data, can omit the modified int
Signed modifying integer data, signed data type
Unsigned modifying integer data, unsigned data types
C. Complex Type Keywords (5)
struct structure Declaration
Union Community statement
enum Enum Declaration
typedef claim Type Aliases
sizeof gets the size of a variable of the specified type of live specific type
D. Storage-level Keywords (6)
Auto is specified as an automatic variable and is automatically assigned and freed by the compiler. Usually allocated on the stack
Static variables, assigned in static variable area, modifier function, specify function scope as inside file
Register is specified as a register variable, it is recommended that the compiler either store the variable in the Register or modify the function parameter, suggesting that the compiler pass the parameter through the register instead of the stack
extern specifies that the corresponding variable is an external variable, that is, the definition of the identity variable or function in another file, prompting the compiler to find its definition in other modules when encountering this variable and function
Const and volatile synthetic "CV" attribute, specified variable cannot be changed as current thread/process (but may be changed by system or other thread/process)
Volatile and volatile synthetic "CV" attribute, the value of the specified variable may be changed by the system or other process/thread, forcing the compiler to get the value of the variable from memory every time
Process Control Keywords
A. Jump Structure (4)
Return is used on the function body, returning a specific value (or void value, which does not return a value)
Continue end the current loop and start the next cycle
Break jumps out of the current loop or switch structure
Goto unconditional Jump Statement (not recommended)
B. Branching structure (5)
If condition statement, there is no need to put the points back.
Else conditional Statement Negation branch (with IF)
Switch Switches Statement (multi-branch statement)
Branch marks in a case switch statement
The "other" branch in the default switch statement, optional
C. Circular structure (3)
For For loop structure
Do-Do loop structure
While loop structure
Understanding functions
C language is composed of functions. A program can consist of multiple functions, but there must be one main function (main function) and only one main function.
int main indicates that the return value type of the main function is int, so you can see return 0 in the last line of the function.
Main (int argc, const char * argv[]), the contents of parentheses represent the parameters of the function.
The function consists of the return value type function name (formal parameter) {function Body}.
The main function is called by the system, and other functions must be declared before they are invoked. Because C-language compilation is a top-down order, it is not necessary to declare a function when it is called in the main function before the main function. Instead, the function needs to be declared when the function is called in the main function after the main function has been defined by the custom function.
Comments
C-Language execution process
Identifier
The hard and difficult point of C language learning
The first C language program