本节主要介绍了文件信息在计算机系统中是以什么形式存储的,比如我们的hello.c源文件,在计算机系统中是如何识别每个字符。
#include <stdio.h>
int main()
{
printf("hello, world\n");
return 0;
}
-
Our hello program begins life as a ==source== program (or source file) that the programmer creates with an editor and saves in a text file called hello.c.
-
The source program is a sequence of ==bits==, each with a value of 0 or 1, organized in 8-bit chunks called ==bytes==.
-
Each ==byte== represents some text character in the program.
-
Most computer systems represent text characters using the ==ASCII== standard that represents each character with a unique byte-size integer value.
![[./1_1.assets/Screenshot 2023-10-04 at 15.27.00.png]]
-
The hello.c program is stored in a file as a sequence of ==bytes==. Each byte has an integer value that corresponds to some character.
![[./1_1.assets/Screenshot 2023-09-26 at 12.46.04.png]]
ascii value of '#' = 35 value in bits: 0b 0010 0011 ascii value of 'i' = 105 value in bits: 0b 0110 1001 ascii value of 'n' = 110 value in bits: 0b 0110 1110 ...
-
finally it will be a binary file in computer system:
0010 0010 0110 1001 0110 1110 ...
-
-
The representation of hello.c illustrates a fundamental idea: All information in a system—including disk files, programs stored in memory, user data stored in memory, and data transferred across a network—is represented as a bunch of ==bits==. The only thing that distinguishes different data objects is the context in which we view them.
0b 0110 1110 can be 110 in integer, 'n' in character ...