This is the 25th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

  1. The essence of double clicking in Windows is to run the program and load our program into memory.

  2. Any program must be loaded into memory before it can be run, and before it is loaded, it must be on hard disk before it is loaded.

    image-20210820145620874


What is a variable (what is it)

A space of a specific size in memory used to hold data

Key word: memory

Essentially variables are created at run time, or some variables are determined at compile time

We usually write code variables are determined while the program is running

How to define variables (how to use them)

Int x = 10;

.

Type variable name = default value

Why variables are defined (why)

Computer is to solve the problem of insufficient computing power and was born, that is, the computer is for calculation. And computing requires data.

Computation, on the other hand, is not something that is computed immediately, so you need something to store it temporarily, so variables are used to store the data temporarily, to be processed later.

Register is the fastest keyword

image-20210820161809631


register

Registers are more like a part of the CPU itself than a memory. They can only hold a very limited amount of information, but they are very fast and synchronized with the CPU.

Cache (CPU Cache)

Cache Memory is a small but high speed Memory located between the CPU and Dynamic Random Access Memory (DRAM). It usually consists of SRAM (Static Random Access Memory)

Memory

Chips using Dynamic Random Access Memory (DRAM) have higher density and more capacity than SRAM chips, and they are also much cheaper than SRAM chips.

The hard disk

For example, solid-state drives (SSDS) and Hard disk drives (HDDS).

What variables can register be used for

  1. Local (global causes CPU registers to be occupied for a long time)
  2. It will not be written to (write to memory, then read to check).
  3. High frequencies are read (for efficiency)
  4. If you do use them, do not use them in large quantities, as the number of registers is limited.

One super important point is that register variables cannot fetch addresses (because they are already in registers, addresses are memory related concepts).

Extern is declared externally

  1. The statement does not open up space,
  2. =100 is assignment or initialization
  3. All variables cannot be declared with an initial value
For example,extern intg_val; Absolutely notextern int g_val = 100;
Copy the code

The header file. H

What’s the easiest way to write a header file

#pragma once // This is to avoid recalling

  1. C header file
  2. Declaration of all variables
  3. Declaration of all functions
  4. #define type typedef, struct

#include<stdio.h>

#include<windows.h>

Static variable static

Static modifies local variables

What changes is the lifecycle, the scope stays the same

image-20210821215721123


image-20210821220245289


Static modifies global variables

Static modifies a global variable that can be accessed only within this file and not directly by external files

image-20210821225646389


image-20210821231545236


image-20210821231946026


image-20210821232916290


So what is he changing? Is it still a global variable? Yeah, it’s still a global variable, it’s still a global variable, it’s a global variable that stays as the whole program is downloaded into memory, becomes a process, so what is it essentially, it essentially means that the life cycle doesn’t change, it changes the scope.

Binary fast conversion formula

Turn ten second

2 ^ 0 < – > 1

2 ^ 1 < – > 10

2 ^ 2 < – > 100

2 ^ 3 < – > 1000

1 followed by n bits is 2 to the n

67   
64+2+1
2^6+2^1+2^0
0000 0000 0000 0000 0000 0000 0100 0011
Copy the code

2 turn ten

0000 0000 0000 0000 0000 0010 0100 0011
2^9+2^6+2^1+2^0
512+64+2+1
579
Copy the code