3.25 notes

The C language is very close to the computer architecture, and can feel the characteristics of computer software and hardware.
c supports cross-platform.
c is very classic and is often used for low-level development and linux os.
(Vs when modifying the code, the code is overwritten because the ovr mode is used by default to overwrite writing. You can directly press the Ins key on the keyboard to switch to insert mode.)

type of data:

	char;          //字符数据类型,内存分配1个字节
	short;         //短整型,内存分配2个字节
	int;           //整形,内存分配4个字节
	long;          //长整型,内存分配4个字节
	long long;      //更长的整形,内存分配8个字节
	float;          //单精度浮点数,内存分配4个字节
	double;         //双精度浮点数,内存分配8个字节
	//在c语言中,是不存在字符串的,如果要使用字符串,需要char *或char []来使用

Why are there so many data types?
Computers are designed to solve human problems, and there are many human computing scenarios. Defining the appropriate data type can improve its efficiency. After the database knows the type of data it needs to process, it can reduce the total storage space and increase the access speed.
Variable: To put it plainly, it is the amount that can be changed.
Global variable: When the program starts to execute, it starts to work and terminates when the program ends. Its scope is the entire project. Its life cycle is the life cycle of the entire program.
Local variable: only works in the local scope where the variable is located. Its life cycle begins when it enters the scope and ends when it leaves the scope.
If the global variable and the local variable have the same name , the local variable will be used first.

#include<stdio.h>
int x = 100;
int main()
{
    
    
	int y = 200;
	int x = 200;
	printf("%d\n", x + y);
	return 0;
}

The output result is: Insert picture description here
constant: an unchangeable amount.
Constants in c language are divided into the following types:

  1. Literal constant:10; 'x';

  2. Constant variables modified by const:const int x = 200;

  3. #define defined identifier constants: #define x 200
    There is a question here, why do we use macros to define identifier constants?
    Two benefits: ① See the name and know the meaning. ②The maintainability of the code can be improved.

  4. Enumeration constant:

#include<stdio.h>
enum people
{
    
    
	man,
    woman
};
int main()
{
    
    
	enum people x = man;
	return 0;
}

Key points:
I am a **, and I am currently studying in graduate school. The current short-term goal is to learn the basics well. This is a gradual process. I hope to become a boss one day. If you plan to learn programming, take a look at classic textbooks and spend a certain amount of time on the computer every day. I will learn programming when I have time, and I will also take time to learn. Currently, the one who wants to enter the most is Huawei.

Guess you like

Origin blog.csdn.net/w903414/article/details/105106665