Specification for identifier naming
Specification content: 1) make a meaningful name 2) follow the camel's name method in general
The core idea:
1, if an identifier has more than one word composition
1) First letter in lowercase, and first letter of other words in uppercase
2) or the first letter of all the words are capitalized
------------------------------------------------
Overview and classification of constants
Constants in the computer: represents fixed data, represented by represented
Categories of constants: Shaping constants, real constants, character constants, string constants
Different types of constant representation methods
1) 10 binary Shaping constants (calculated by default using 10 binary constants to represent integers)
10;
18;
2) 8 binary integer constant
Start with 0
045; This is a 8 binary integer, Myth: not 10 binary 15
3) 2 binary integer constant
Start with 0b (0B)
0b11111111111111111111111111111111
Represents a-1
, &NB Sp , &NB Sp , &NB Sp , &NB Sp , &NB Sp , &NB Sp , &NB Sp , &N Bsp , &NB Sp , &NB Sp , &NB Sp , &NB Sp , &NB Sp , &NB Sp  
4) 16 Binary integer constant
Start with 0x
0X438FA;
This is a 16-binary integer
2. Representation of real (fractional) constants
1) Single-precision constants
End With F
2.3f; A decimal that represents a single precision occupies 4 bytes
2) Double-precision constants
2.3; The default representation of a decimal number in a computer as double precision
3, character type constant representation
A single character enclosed in single quotation marks (' '), which can be a character, a number, a symbol, or an expression character constant.
' A ';//1
‘*‘;
' & '; It's all character constants.
' AB '; Not legal.
Special character constants (escape characters)
' \ n ';
' \ t ';
‘\\‘;
' \ r '; This is also a character constant (a special character constant, which is an escape character)
4. String constants
Enclosed in double quotes, it can be a character, a number, a symbol.
"ABC"; A b C
"A"; A-2
"**";
" "; Contains a space
""; empty string, nothing.
--------------------------------------------------------
1. Variables:
Represents a space for memory that is used to store frequently changing data
2.2 Elements of a variable: 1) Variable type 2) variable name
The name of the variable is the basis of our action variable (Access data)
3, the classification of variables:
Global variables and local variables
4, the use of variables
1) Define a variable
How do I define a variable?
Format: The name of the variable's type variable;
int A; A variable of type int (4 bytes) is defined, and the variable name is a
Char ch; A variable of type char is defined, and the variable name is CH
float F1;
Defining multiple variables at once
Format 2: Variable type variable name 1, variable name 2, variable name 3;
int a,b,c,d;
4 variables of type int are defined, variable names are a,b,c,d
naming conventions for variable names
1) Strict adherence to the naming conventions of identifiers
int #123;
2) variable name cannot have the same name (in some cases)
int A, B;
int b;
Variable A that defines an int integral type
Does a have a value at this point? has a value
The probability of a value: 1) data of the System 2) data remaining on a program 3) Number of garbage
Since the variables are set, it is worthwhile, in order to prevent the original value of the variable from affecting our program, I want to initialize
Initializing: Assigning an initial value to a variable
Initialize the method:
1, the definition of simultaneous initialization
1) Full initialization
Initialized format: Variable name = variable Value
int num1=0,num2=0; Two variables of type int are defined, the variable names are NUM1 and num2
The value of NUM1 is 0 num2 and the value is 0.
2) Partial initialization
int num3=0,num4; Two variables of type int are defined, the value of//NUM3 is 0 num4 we don't know.
2. Define variables first, then initialize
int num5,num6;
3. Use a variable to initialize another variable
int num7 = NUM5; Initialize the num7 with the value of NUM5
4. Continuous initialization for variables
int NUM8,NUM9,NUM10;
NUM8 = NUM9 = num10=10; To NUM8 num9 NUM10 are assigned value of 10;
use of variables: stored values and values
int A; 0 NIL Null Other
A = 0; 0
printf ("A =%d", a);
A = 23; 23 setting the value of a
int NUM11 = A; A NUM11 23, first take out a value of 23, and then assign to NUM11
printf ("a =%D,NUM11 =%d\n", A,NUM11);
Note about the use of variables:
The left side of the equals sign must be a variable
A = 34;
The right side of the equals sign can be a variable, a constant, an expression
A = 10+19; 29
Must not write a constant on the left side of the equals sign
34 = 1;
-------------------------------------------------
Scope: Can be understood as a range of variables that can be used
Variables are categorized by scope: Local variables and global variables
1) Local Variables:
A variable that is internally defined within a function or a block of code, called a local variable.
Code block:
{
code block statements;
}
{
Code Block 2
}
Emphasize one thing:
Blocks of code can be nested
{
Code block statements
{
Code block statements
}
}
Scope of local variables:
Starting at the location defined by the local variable, to the block of code it is in or the "}" of the function body
Attention:
Within a block of code you can define a variable with the same name as the outside of the block, and the scope of the variable inside the block is temporarily masked (outside of the non-functional) block
2. Use of global variables
Variables defined outside of the function are global variables
Scope:
From the defined position to the end of the file, you can use it in different functions.
---------------------------------------------------------------------
<02> keyword + identifier + constant representation + variable + scope