当前位置:网站首页>Rough notes of C language (1)
Rough notes of C language (1)
2022-07-05 07:18:00 【After reading thousands of books, you can pick them up and put 】
C Language is a computer language —— The language of human and machine communication (c Language ,c++,JANA,Python)
Computers have to develop —— Early recognition is binary .
Computers are hardware , Electrify , Electricity Division , Positive and negative , Used in computers 0 Means negatively charged ,1 Indicates positive electricity , All computers can handle are electrical signals ,0,1 Such a signal , Binary language . So to run a program, you just need to give it a binary sequence .
At the beginning of a program, you need to type a large string of code, such as :100001110110
It's too hard to remember these , So people wonder if they can give a name to a program instruction represented by a piece of code
Such as 1000011——ADD( Mnemonic symbol )
In the future, just fight ADD Just fine , It knows or turns into 1000011.
And this mnemonic is assembly language .
In the later development, people wanted one sentence to represent many strings of code , There was also B Language ——C Language ,C++,……( High-level language )
C Language —— Early immaturity —— mature —— popular
Early immaturity : Each company has its own customized functions , So every company has its own customized functions , My house c Language can't pass in your compiler software , I can't pass in his compiler . Then international standards appeared .
ANSICC( The National Bureau of standards )——C89( Launched in 2013 )/C90 (89,90 be similar )
later ISO cognizance C89 For thorough International Standards .
C99/C11 It's not popular , Many compilers do not support , Only by the same standard can it become popular , In order to run in various compilers .
C Language is a process oriented computer programming language , And C++,JAVA, Object oriented programming languages such as , Its compiler mainly includes Clang、GCC、WIN-TC、SUBLIME、MSVC、Turbo C etc. .
first C Language program
.c—— Source file
.h—— The header file 
Main
: The main function : Program entrance , The program from main The first line entry of the function , No addition main Function, it doesn't know which line to start with .
How many more ?
Also, there are too many entrances. It doesn't know where to start . So the main function has and only has one , It can't be without .
data type


To put A There is room for saving , Now let's apply for a space from the computer memory , Give Way ch Take the application and place the space name ch, To store characters A.
Common data types correspond to print symbols
%c// Print data types in character format ;
%d// Print integer decimal data types ;
%f// Print floating point numbers ;
%p// Print in the form of an address ;
%x// Print in hexadecimal data type ;
Why are there so many types ?
What is the size of each type ?
answer : The range of values is different , To reduce memory , The corresponding number corresponds to the type , Different space occupied .
C Language standards sizeof(long)>=sizeof(int)
The current operating system has developed to 64 Bit operating system , However, due to the different process of program compilation , The two show different differences :
32 Bit compiler system :int Four bytes , And long identical .
64 Bit compiler system :int Four bytes ,long Occupy 8 byte ,long The data range becomes :-263~263-1
Sizeof():
Calculation xx The amount of space taken up , Unit byte ;
Units in a computer
A computer is a piece of hardware , Electrify , It recognizes electrical signals , Positive and negative electricity Division , Positive for 1, Negative is 0, The electrical signal is converted into a signal that the computer can recognize 1 and 0. Computer can recognize positive and negative , Prove that it can recognize 1 and 0 Such a signal .
that 1 and 0, Such instructions need space to store , Deposit 1 or 0 Such a space size is a bit .( Store a binary bit ).
A byte 8 A bit ;
For example, there are three bits 23 There are two possibilities and the largest data is 23-1;
Sixteen bits have 216 There are two possibilities and the largest data is 216-1;
Report errors ,
float
It's single precision ,95.6 It is regarded as double precision
So sometimes in 95.6 After add f Just fine . But sometimes you can't just change .

Variable

Global variables : Defined in the code block ({}) Other variables ;
local variable : Defined in the code block ({}) The variables within ;
&: Address fetch , Tell him to put this input data here .
The computer memory is very large, so it is convenient to divide the memory into small pieces , Easy to find , For example, get the address directly num1;
Local variables can only be used in {} Use in ;
It is recommended that the names of local variables and global variables should not be the same . Easy to produce bug
When local variables and global variables exist at the same time, local variables have priority ;
The scope and life cycle of variables
Scope : The concept of programming , Generally speaking , The names used in a program are not always valid / Usable . The scope of the available code that limits the name is the scope of the name .
Scope of variable
:
- The scope of a local variable is the local scope of the variable ;
- The scope of global variables is the whole project ;
extern Declaration of external symbols


shazi, Put it in the code block {} Calculate the global variables ;
Life cycle :
The life cycle of a variable is the period between the creation of a variable and its destruction .
4. The life cycle of a local variable is : Enter the beginning of the scope lifecycle , Work or end of life cycle ;
5. The life cycle of global variables is : The whole life cycle of the program .
边栏推荐
- 【无标题】
- ORACLE CREATE SEQUENCE,ALTER SEQUENCE,DROP SEQUENCE
- 乐鑫面试流程
- 【软件测试】04 -- 软件测试与软件开发
- Literacy Ethernet MII interface types Daquan MII, RMII, smii, gmii, rgmii, sgmii, XGMII, XAUI, rxaui
- 你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?
- ModuleNotFoundError: No module named ‘picamera‘
- 2022年PMP项目管理考试敏捷知识点(7)
- 并发编程 — 如何中断/停止一个运行中的线程?
- 基于Cortex-M3、M4的GPIO口位带操作宏定义(可总线输入输出,可用于STM32、ADuCM4050等)
猜你喜欢

SOC_ SD_ DATA_ FSM

Logical structure and physical structure

Negative number storage and type conversion in programs

Netease to B, soft outside, hard in

Inftnews | drink tea and send virtual stocks? Analysis of Naixue's tea "coin issuance"

Machine learning Seaborn visualization

And play the little chestnut of dynamic agent

一文揭开,测试外包公司的真实情况

Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required

docker安装mysql并使用navicat连接
随机推荐
睿智的目标检测59——Pytorch Focal loss详解与在YoloV4当中的实现
并发编程 — 死锁排查及处理
[software testing] 05 -- principles of software testing
Brief description of inux camera (Mipi interface)
Application of MATLAB in Linear Algebra (4): similar matrix and quadratic form
Hdu1231 maximum continuous subsequence (divide and conquer or dynamic gauge or double pointer)
Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required
Qu'est - ce que l'hydroxyde de sodium?
golang定时器使用踩的坑:定时器每天执行一次
【软件测试】04 -- 软件测试与软件开发
[software testing] 04 -- software testing and software development
2022.06.27_ One question per day
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
Special training of C language array
Unconventional ending disconnected from the target VM, address: '127.0.0.1:62635', transport: 'socket‘
And play the little chestnut of dynamic agent
Matlab在线性代数中的应用(四):相似矩阵及二次型
HDU1231 最大连续子序列(分治or动规or双指针)
Altimeter data knowledge point 2
【软件测试】05 -- 软件测试的原则