Those things that bug bacteria beginners don't understand when learning C language~

427202927317ffa8404b2ce9862b29e4.gif

text


Hello everyone, I am a bug~

In fact, the syntax of C language is very simple. It can be said that it is a programming language with the least grammatical points among mainstream programming languages. However, C language also has its complicated side, which lies in its platform differences. The current CPU, operating system, compiler, etc. to guide programming.

The following bug summarizes a small part of knowledge, so that everyone can understand some of the content that is not so special when learning C language:

1

Compilation of C files

In C language, .c files are usually used as source files, and source files are compiled independently before linking, that is, .c files can be finally compiled into target .o files in parallel.

However, usually we see that the .h files are just to allow the interfaces provided by each C language to call each other, and finally link them into the final execution file.

After understanding this layer, you should have a well-organized file structure.

2

data type fixed

A colleague used to say that C language is a "programming language with known data types", but he didn't pay much attention to it at the time.

In fact, with your rich programming experience, you will find that if you don't know the specific size of the data during the programming process, you will probably have problems during the assignment or copy process.

3

C language memory

The memory of C language is simple and generally speaking, there are two types - heap and stack. The stack belongs to dynamic memory, which is necessary for our C language to run the call stack, while the heap is static memory, and the combination of dynamic and static constitutes the memory in the program. operation.

The dynamic memory allocation malloc and so on that we usually encounter are just ways to use static memory for space to improve utilization.

4

struct programming

Struct can be said to be the most direct syntax of C language OO. Data and methods can be packaged and taken away, packaged and accessed, so as to make the data more cohesive and more targeted when used.

5

static and const

Both static and const contribute to the safe use of data and methods. C language is a simple and flexible programming language. If you are too free, you are more likely to make mistakes; then these two keywords can be used to a certain extent. Functions and variables are constrained to improve the robustness of the program.

The key is that you have a good understanding of the program and consider them when programming.

6

Data size and unsigned

The actual memory usage size of integer numbers on different platforms may be different, and the C standard usually only stipulates its minimum size, so you should know it in advance before coding.

Similarly, the char type is not necessarily always 8bit, usually it represents the minimum addressing size of the current embedded platform.

Also, the char type is mostly considered to be a signed type, but signed is omitted. However, it is not stipulated in the C99 standard, and it has to depend on the platform or compiler.

at last

      Well, I will share so much with you today, if you feel that you have gained something, please remember to like it ~

The only, permanent and free sharing embedded technology knowledge platform for bug bacteria~

98a1380d09d73758f3673691e0409ae8.jpeg

Recommended albums Click on the blue font to jump

☞   MCU Advanced Album dc3022347dc7edce43cb863115f86883.gif

☞Embedded   C language advanced album 1df824230253dcf7febfe39fb2e14201.gif

☞   "bug talk" album f61400ff486d202afe7c5fffd654e958.gif

☞Album  |Linux Application Programming Encyclopedia

☞Album  |Learn some network knowledge

☞Album  | Tear C Language

☞Album  | Tear C++ language by hand

☞  Album | Experience Sharing

☞Special  | Power Control Technology

☞Album  | From MCU to Linux

a242f0aa17dc4e7ccb516ea2f0d2f061.gif

Guess you like

Origin blog.csdn.net/qq_33471732/article/details/132138157