C language Xiaobai learning journey fifth

learning target:

We can't understand the difficult ones. Let's read the simple ones first. Come on!

study-time:

November 1, 2020

Learning output:

Callback function learning: To put it
plainly, a callback function is a function called through a function pointer. If you pass the function pointer Callback (address) as a parameter to another function, when this pointer is used to call the function it points to, we say that this is a callback function.

#include<stdio.h>
int Callback_1()
{
printf(“Hello, this is Callback_1 \n”);
return 0;
}

int Handle(int (*Callback)())
{ Callback(); //callback function }

int main()
{
Handle(Callback_1);
return 0;
}

Static library: When compiling and linking, all the code of the library file is added to the executable file, so the generated file is relatively large, but the library file is not needed at runtime [General format xxx.a file]
Dynamic library : When compiling and linking, all the code of the library file is not added to the executable file, but the library is loaded by the running link file when the program is executed, which saves the system overhead [file of general format xxx.so]
gcc is compiling The default is to use dynamic libraries

Static global variable: It is only valid in the file where it is defined [for example, it cannot be accessed using the extern keyword in other files].
Global variables: valid in the entire project file [for example, using the extern keyword can be used in other files].
Static local variable: only valid in the function that defines it, and the program allocates memory once, the variable will not disappear after the function returns.
Local variable: valid in the function that defines it, local variable is invalid after the function returns

Four memory areas:
stack area: automatically allocated and released by the compiler, storing function parameters, local variables, etc., and automatically released.
Heap area: manually allocated and released by the programmer [dynamic memory application and release].
Global area: used to store global variables and static variables, there is a constant area subdivided inside to store string constants and other constants.
Code area: store machine instructions executed by the CPU. This area is usually institutional, preventing the program from accidentally modifying its instructions.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_33565495/article/details/109413050