当前位置:网站首页>C language Essay 1

C language Essay 1

2022-07-05 05:15:00 qq_ forty-three million two hundred and five thousand two hundr

1. Memory unit conversion

Unit conversion :

  • 1Byte ( byte )= 8 Bit( bits )
  • 1KB = 1024Byte = 210Byte
  • 1MB = 1024KB = 220Byte
  • 1GB = 1024MB = 230Byte
  • 1TB = 1024GB = 240Byte
  • 1PB = 1024TB = 250Byte
  • 1EB = 1024PB = 260Byte

 

 

2. Software operation logic

Whether it's running QQ Or editor Word file , First copy the data on the hard disk to the memory , To make CPU To deal with it , This process is called loading memory (Load into Memory). This process requires a special program ( Software ), This program is called loader (Loader).

CPU Dealing directly with memory , It reads the data in memory for processing , And save the results to memory . If you need to save to hard disk , Will copy the data in memory to the hard disk .

e6e82a79646a4f34af818806a5d34d05.png

 

 

 

3. The concept of Libraries

Libraries are generally divided into two types :

  • When developers of programming languages develop programming languages , Commonly used code should be written in advance , Or common functions , For example, input and output 、 Mathematical calculation 、 File operations 、 Network operating 、 Date time 、 Error handling 、 String processing, etc , These official libraries are called standard libraries (Standard Library), They are released with the programming language , It can be recognized that it is a part of programming language .
  • Some organizations or individuals will also develop some libraries , Some are for profit , Some are hobbies , There are some codes that our company is using , Open source benefits mankind , These libraries are called third-party libraries (Third-party Library).

 

 

 

4. The difference between full angle and half angle input methods

On the computer screen , A Chinese character should occupy the position of two English characters , The position occupied by an English character is called “ Half angle ”, Relatively speaking, the position occupied by a Chinese character is called “ Full angle ”.

Punctuation 、 English letter 、 Arabic numerals and other characters are different from Chinese characters , In the half angle state, they are treated as English characters , In the full angle state, it is treated as Chinese characters , Please see the following example .

Half angle input :

Hello C,I like!

Full angle input :

Hello C,I like!

 

 

 

5. What is a source file

In the process of developing software , We need to put the written code (Code) Save to a file , So the code won't be lost , To be found by the compiler , To eventually become an executable . This kind of file used to save code is called source file (Source File).

The source files of each programming language have a specific suffix , To be recognized by the compiler , Understood by programmers . Source file suffixes are mostly named according to the name of the programming language itself , for example :

  • C The suffix of the language source file is .c;
  • C++ Language (C Plus Plus) The suffix of the source file is .cpp;
  • Java  The suffix of the source file is .java;
  • Python  The suffix of the source file is .py;
  • JavaScript  After the source file is .js.


The source file is actually a plain text file , There is no special format inside it , A typical example of this conclusion is : stay Windows Next, use Notepad program to create a new text document , And named it demo.txt, Enter a paragraph C Language code and save , Then forcibly rename the file to demo.c( Suffix from .txt Turned into .c), It is found that the compiler can still correctly recognize C The language code , And successfully generate executable files .

The suffix of the source file is only to indicate that the code of a language is saved in the file ( for example .c What's in the file is C The language code ), This makes it easier for programmers to distinguish , The compiler is also easier to recognize , It does not cause the internal format of the file to change .

 

 

 

 

 

6. Compile and link

compile (Compile)

C Language code is organized by fixed vocabulary and fixed format , Simple and intuitive , Programmers are easy to identify and understand , But for CPU,C Language code is the book of heaven , I don't know ,CPU Only a few hundred instructions in binary form are known . This requires a tool , take C Language code into CPU Binary instructions that can be recognized , That is to process the code into .exe The format of the program ; This tool is a special software , be called compiler (Compiler).

The compiler can recognize words in the code 、 Sentences and specific formats , And convert them into binary forms that computers can recognize , This process is called compile (Compile).

Compilation can also be understood as “ translate ”, It's similar to translating Chinese into English 、 Translate English into hieroglyphs .

C There are many compilers for languages , There are different compilers on different platforms , for example :

  • Windows The commonly used is developed by Microsoft  Visual C++, It's integrated into Visual Studio in , Generally not used alone ;
  • Linux The most commonly used is GUN Developed by the organization  GCC, quite a lot Linux The distribution comes with GCC;
  • Mac The most commonly used is  LLVM/Clang, It's integrated into Xcode in (Xcode Previously integrated GCC, Later due to GCC It's not fit to be changed to LLVM/Clang,LLVM/Clang Performance ratio of GCC More powerful ).


Whether your code syntax is correct or not , The compiler says it , We learn C Language , In a sense, learning how to use the compiler .

The compiler can 100% Make sure your code is grammatically correct , Because even a little mistake , Compilation doesn't work either , The compiler will tell you what's wrong , It's easy for you to change .

 

link (Link)

C After the language code is compiled , No final executable was generated (.exe file ), Instead, a file called the target file is generated (Object File) In between ( Or temporary files ). The object file is also in binary form , It is in the same format as the executable . about Visual C++, The suffix of the target file is .obj; about GCC, The suffix of the target file is .o.

The target file is linked (Link) It can become an executable file later . Since the format of the object file and the executable file is the same , Why link again , Can't it be directly used as an executable file ?

No good ! Because compilation just turns the code we write into binary form , It also requires and system components ( For example, standard library 、 Dynamic link library, etc ) Combine , These components are necessary for the program to run .

link (Link) It's really just a “ pack ” The process of , It combines all binary object files and system components into an executable file . The process of completing the link also requires a special software , be called The linker (Linker).

With the deepening of our study , We write more and more code , Eventually, you need to distribute them into multiple source files , The compiler can only compile one source file at a time , Generate a target file , This is the time , The linker combines the target file and system components , You also need to combine multiple object files generated by the compiler .

Again , Compilation is for a source file , You need to compile as many source files as you have , How many target files will be generated .

 

 

 

 

7.C What are the language compilers

The figure below shows the above C Classification of language compilers

9353269537424a3b9d7ffe34d06d90a3.png

 

 

 

 

 

 

8.  What is? IDE( Integrated development environment )

In development , Except that compilers are necessary tools , We often need a lot of other assistive software , for example :

  • Editor : To write code , And color the code , To facilitate reading ;
  • Code prompt : Enter part of the code , You can prompt all the codes , Speed up the code writing process ;
  • The debugger : Observe every running step of the program , Find the logic error of the program ;
  • Project management tools : Manage all resources involved in the program , Including source files 、 picture 、 video 、 Third party library, etc ;
  • Beautiful interface : All kinds of buttons 、 panel 、 menu 、 Windows and other controls are arranged neatly , Easier to operate .


These tools are usually packaged together , Unified release and installation , for example Visual Studio、Xcode、Visual C++ 6.0、 etc. , They are collectively referred to as integrated development environments (IDE,Integrated Development Environment).

An integrated development environment is a combination of a series of development tools . It's like a desktop , The core component of a desktop is the host , With a host, you can work independently , But when we buy desktops , It often comes with a monitor 、 keyboard 、 mouse 、U disc 、 Cameras and other peripherals , Because only the host is too inconvenient , You must have peripherals to play well .
 

 

 

 

9. What is engineering / project ?

A real program ( It can also be said that software ) It often contains multiple functions , Each function requires dozens or even thousands of lines 、 Tens of thousands of lines of code , If we put all this code in one source file , It's going to break down , Not only does the source file open very slowly , Code writing and maintenance will also become very difficult .

In actual development , Programmers classify these codes into multiple source files . In addition to these thousands of lines of code , A program often includes pictures 、 video 、 Audio 、 Control 、 library ( It can also be said that the framework ) Other resources , They are also files one by one .

In order to effectively manage these kinds of complexity 、 A large number of documents , We have reason to put them all in one directory ( Folder ) Next , And this directory only stores resources related to the current program . actually IDE That's what it did , It will create a special directory for each program , Put all the files you need into this directory , And manage them conveniently , Such as renaming 、 Delete file 、 Edit files, etc .

This is a dedicated folder for the current program , stay IDE There is also a special name in , be called “Project”, Which translates as “ engineering ” perhaps “ project ”. stay Visual C++ 6.0 Next , This is called a “ engineering ”, And in the Visual Studio Next , This is also called a “ project ”, They're just words “Project” It's just a different translation , It's actually a concept .

 

 

 

 

 

10. Concept of header file

And the last question , In the example, No 1 Yes

#include <stdio.h> What does that mean ?

C Language developers have written many commonly used functions , And put it in different documents by categories , These files are called header files (header file). Each header file contains several functions with similar functions , When a function is called , To import the corresponding header file , Otherwise, the compiler cannot find the function .

actually , Header files often contain only descriptions of functions , That is, tell us how to use the function , The function itself is saved in other files , Only when you link .
原网站

版权声明
本文为[qq_ forty-three million two hundred and five thousand two hundr]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050507215040.html