当前位置:网站首页>Part I - Fundamentals of C language_ 1. Overview of C language
Part I - Fundamentals of C language_ 1. Overview of C language
2022-07-19 09:33:00 【qq_ forty-three million two hundred and five thousand two hundr】
1.1 C Language
Language is communication between people ,C Language is the communication between man and machine .
Languages have unique grammatical rules and definitions , Programmers must follow these rules and definitions to communicate with computers .
1.1.1 Computer structure composition

The computer is made up of three parts : Input 、 processor 、 Output .
It is important to understand , The arithmetic unit reads data from the register 、 Register reads data from memory 、 Memory reads data from external storage .
1.1.2 Computer system composition

Just mix a familiar face here , Have a general understanding of what constitutes a computer system . Later, you will become familiar with these components .
1.2 Why study C Language
1.2.1 C Language features
1) advantage
- Fast execution
- Powerful
- Programming Freedom
2) shortcoming
- Writing code takes a long time
- Poor portability
- Rely more on platform libraries
1.2.2 Study C Language reasons

1.2.3 C Language applications
C Language is widely used , From the website background , The underlying operating system , From multimedia applications to large-scale online games , All can use C Language to develop :
- C Language can write website background program
- C Language can write powerful program libraries for a specific topic
- C Language can write the engine of large-scale games
- C Language can write operating system and driver , And only use C Language writing
- As long as any device is equipped with a microprocessor , All support C Language . From microwave ovens to mobile phones , It's all by C Language technology to promote

1.2.4 C What language needs to learn
C Language only 32 Key words ,9 Control statements ,34 Operator , But it can complete countless functions :



Let's make a face , About how much to learn .
1.2.5 Study C Common confusion

1.3 first C Language program :HelloWorld
1.3.1 To write C The language code :hello.c
#include <stdio.h>
int main()
{
printf("hello world\n"); // The first code
return 0;
}stay VS Enter the above code on (VS The installation and preliminary use of... Should be carried out by yourself B Find a video on the station to learn , About half an hour to master ).
1.3.2 The code analysis
1) include The header file contains
- #include The header file contains ,#include <stdio.h> The representative contains stdio.h This header file
- Use C The language library function needs to include the header file corresponding to the library function in advance , As used here printf() function , Need to include stdio.h The header file
#include< > And #include "" The difference between :
- < > The presentation system direct Search according to the directory specified by the system
- "" The presentation system First stay "" Specified path ( No written path represents the current path ) Find the header file , If you can't find it , Again Search according to the directory specified by the system
2) main function
- A complete C Language program , Is written by a 、 And only one main() function ( Also called principal function , There has to be ) Combined with several other functions ( Optional ).
2. main The function is C The entrance to language programs , The program is from main The function starts executing .
3) {} Brackets , Program body and code block
- {} It's called a code block , There can be one or more statements inside a code block
- C Every sentence of executable code in the language is ";" End of semicolon
- be-all # Beginning line , All represent precompiled instructions , There is no semicolon at the end of the precompiled instruction line
- All executable statements must be in code blocks
4) notes
- // Call line comment , The contents of comments are ignored by the compiler , The main function of comments is to add some descriptions and explanations to the code , This is good for reading the code
- /**/ It's called a comment
- Block annotation is C Language standard annotation method
- The line comment is from C++ The language is borrowed from
5) printf function
- printf yes C Library functions , The function is to output a string to the standard output device
- printf(“hello world\n”); \n It means to return to the bus for a new line
6) return sentence
- return Represents that the function has been executed , return return Some values
- If main The definition is preceded by int, that return Then you need to write an integer ; If main The definition is preceded by void, that return You don't need to write anything later
- stay main Function return 0 Represents the successful execution of the program ,return -1 On behalf of program execution failure
- int main() and void main() stay C It's the same in language , but C++ We only accept int main This way of defining
The above analysis of each part of the code can be understood first , As you continue to study in depth, you will naturally understand .
1.4 C Language compilation process
1.4.1 C Program compilation steps
C The code is compiled into an executable program after 4 Step :
- Preprocessing : Macro definition expansion 、 Header file expansion 、 Conditional compilation, etc , At the same time, delete the comments in the code , There is no inspection here Check grammar ( Generate .i file )
- compile : Check grammar , Compile the preprocessed file to generate assembly file ( Generate .s file )
- assembly : Generating assembly file into object file ( Generate .o file )
- link : C Programs written in language need to rely on various libraries , So after compilation, you need to link the library to the final executable Go in the program ( Generate .exe file )

边栏推荐
猜你喜欢
随机推荐
岚图梦想家的产品力到底如何?
2022-07-16:以下go语言代码输出什么?A:[];B:[5];C:[5 0 0 0 0];D:[0 0 0 0 0]。 package main imp
【C语言】指针练习题2——笔试真题及解析
OpenCV模板
Classificateur knn
Flink small knowledge -- configuration of task scheduling slots slotsharinggroup
MySQL -- SQL optimization case -- implicit character encoding conversion
【网络研究院】机器学习系统的威胁是时候该认真对待了
Pyodide 中实现网络请求的 3 种方法
第一部分—C语言基础篇_2. 数据类型
Anycontrol demo demo demo
How is MySQL data stored on disk?
C51 常见数据类型详解
[fishing artifact] UI library second low code tool - form part (II) sub control
idea卡顿且报错:UI was frozen for xxxxx ms问题解决
Utility series - xshell installation, download and use
ETH的拐点可能指日可待,这就是如何
Markdown (5): anchor link
使用 Golang 正确处理五大互联网注册机构的 IP 数据
Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS) (found suitable exact version “11.4“)

![[英雄星球七月集训LeetCode解题日报] 第17日 宽搜](/img/92/9b8e3a710430d37564d7ea3f28168f.png)






