Summary of C Programming Language Functions
On the whole, the C programming language code is composed of functions one by one. Except for the statements that define and describe classes (such as variable definitions, macro definitions, type definitions, etc.), which can be placed outside the function, all have operational or logical processing capabilities Statements (such as addition, subtraction, multiplication and division, if else, for, function calls, etc.) must be placed inside the function.
For example, the following code is wrong:
#include <stdio.h>
int a = 10;
int b = a + 20;
int main(){
return 0;
}
int b = a + 20;
is a statement with operation function and should be placed inside the function.
But the following code is correct:
#include <stdio.h>
int a = 10;
int b = 10 + 20;
int main(){
return 0;
}
int b = 10 + 20;
will be optimized to
int b = 30;
at compile time , eliminating the addition operation.
Among all functions, main() is the entry function, there is only one, and the C programming language program starts to run from here.
The C programming language not only provides a wealth of library functions, but also allows users to define their own functions. Each function is a reusable module, and complex functions can be implemented in an orderly manner through mutual calls between modules. It can be said that all the work of a C program is done by various functions, and functions are like parts one by one, combined together to form a powerful machine.
Standard C programming language (ANSI C) defines a total of 15 header files, called "C standard library", which all compilers must support. How to use these standard libraries correctly and proficiently can reflect the level of a programmer.
-
Qualified Programmers: <stdio.h>, <ctype.h>, <stdlib.h>, <string.h>
-
Skilled programmer: <assert.h>, <limits.h>, <stddef.h>, <time.h>
-
Good Programmers: <float.h>, <math.h>, <error.h>, <locale.h>, <setjmp.h>, <signal.h>, <stdarg.h>
The above functions are not only numerous, but also require hardware knowledge to use. It takes a long learning process for beginners to master all of them. My suggestion is to master some of the most basic and commonly used functions first, and then go deeper in practice.
It should also be noted that all function definitions in the C programming language, including the main function main(), are parallel. That is to say, in the function body of a function, another function cannot be defined, that is, it cannot be nested. But functions are allowed to call each other, and nested calls are also allowed. It is customary to refer to the caller as the calling function and the callee as the called function. Functions can also call themselves, called recursive calls.
The main() function is the main function, it can call other functions and is not allowed to be called by other functions. Therefore, the execution of a C program always starts from the main() function, returns to the main() function after calling other functions, and finally ends the entire program by the main() function.