当前位置:网站首页>2022.1.21 diary

2022.1.21 diary

2022-06-25 05:16:00 LF19971222

The global variables of a file are defined as static variables , This means that this variable can only be called by this file . Functions with the same name in other files do not conflict ; However, its application scope is limited .

const The modifier is a read-only variable . It can increase and decrease itself .

int const *a=const int *a

Int *const a;a It's a point int Type const The pointer ,*a It can be rewritten , but a Overwrite not allowed . So this situation must be a=&i; the a initialization .

int const * const a;

a It's a point const int Type const The pointer , therefore *a and a Are not allowed to rewrite .

 extern Default statement , Expand the use of variables .

struct: A whole that combines multiple data , Its manifestation is a structure .

Form new data types .

Memory space is allocated to variables , Not assigned to a data type .

struct node

{............

};        The semicolon here should not be forgotten .

 

 C Member operators in languages :. 、→.

Array names cannot be used as group values .

 

Structural variables cannot be input and output as a whole .

printf(“%d%s%f”,stu1);scanf(“%d%s%f”,&stu1); error !

You can only input and output one by one .

 

  Fixed length initialization

Two square brackets for a two-dimensional array , Only the first one can be empty .

 

Only short Type , Then account for 2 Byte half word alignment .

Yes int Type , Then account for 4 Byte word alignment .

None of the above , One by one .

Union share ( union ) body : When multiple basic data types or composite data structures occupy the same piece of memory , We're going to use the consortium .

Big_endian Big endian byte order : The high byte bits of the data are stored in the storage unit corresponding to the low address ;

Little_endian Small endian byte order : The low byte bits of the data are stored in the storage unit corresponding to the low address .

Strings are processed with character arrays , There is no concept of byte order .

Enum: Enumeration type

enum The default value of :

Enum kids{nippy,slats,skippy,nina,liz};

enum Specified value of :

Enum levels

{low=100,medium=500,high=2000};

enum Usage of : As switch The label of .

Typedef: yes C Keywords of language , Its purpose is to define a new name for a data type .

Format : typedef data type Custom data types

Define constants and commands ( Avoid magic numbers )

#define MAX 100    Macro name Macrobody

# It starts with preprocessing commands

The preprocessing process is called macro expansion or macro replacement

Simple structure 、 Use a high frequency algorithm to write macro functions .

debugging :

#if 0/1

.....

#endif

Floating point numbers cannot be compared with zero .

Zero of the pointer is null .

Current loop :for、while、do while

C The language doesn't go until the loop

a、b Exchange three ways :

  1. a=a+b;b=a-b;a=a-b
  2. a=a^b;b=a^b;a=a^b
  3. t=a;a=b;b=t

In multiple loops , If possible , The longest loop should be placed on the innermost layer , The shortest cycle is on the outermost layer , In order to reduce CPU The number of times that the cyclic layer is cut across .

If there is logical judgment in the circulatory system , And the number of cycles is very large , The logical judgment should be moved outside the loop body .

goto Use occasion : In multiple nesting , Use when transferring from the innermost to the outermost . In the same function !

An operation :

&: Bitwise AND , The corresponding bits are 1 Only when 1, Otherwise 0

|: Press bit or , The corresponding bits are 0 Only when 0, Otherwise 1

^: Bitwise XOR : When the corresponding bits are the same, it is 0, Different at the same time 1

~: According to the not : Everybody, reverse , That is, the original 1 The bit becomes 0, Originally for 0 The bit becomes 1( It is mainly used to construct a number indirectly , To enhance the portability of the program )

>> Right shift to position : Is the right shift of each bit of the operand , Move out of the low abandon ; High position :(1) For unsigned numbers and positive numbers in signed numbers , repair 0;

(2) A negative number in a signed number , Depends on the system used : repair 0 Of is called “ Logical shift right ”, repair 1 Of is called “ Arithmetic shift right ”. for example ,20>>2=5.

原网站

版权声明
本文为[LF19971222]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210519241340.html