One. Basic data type Knowledge points
The basic data type in 1.c/c++ is.
: integral type, floating point type, character type, no value type
2. How the basic data types are subdivided.
: Integral type includes: Signed Long Integer (signed long int), unsigned long integer (unsigned long int), signed short integer, unsigned short integer type.
3. Type modifier Signed,short,long usage:
(1) Type modifiers signed and unsigned are used to modify character types and shaping.
By default, when a number is declared, the default is a signed type, that is, the signed
(2) Type modifiers short and long are used to modify character types and shaping.
(3) int can be omitted when the int is shaped with signed and unsigned, short and long. As short i = 2;
(4) in which bool and wchar_t are specific to C + +.
4. How to declare long and float type.
By default, the compiler takes a floating-point number as a double and, to force float, adds "F" or "F" at the end, such as float i = 3.14f
When declaring a long integer, add L or L at the end, such as long i = 312L;
5. Floating-point and science and technology Law:
E or E indicates an exponent, the size of which can be
4. Constant Knowledge Points:
When the constants are used.
: If you use a number frequently in a program, it's annoying to repeatedly enter this number, and you can declare a constant to represent it. And if you need to change this worth, just modify one of the programs.
such as: const double PI = 3.14;
1 Declaration of variables, initialization of knowledge points
Note: In any case, it is best to complete the declaration and initialization of the variable in a single statement.
1. Variables must be declared and initialized at the same time:
1 Local variables (variables within the function, otherwise the value is unpredictable)
Two. Operator Knowledge points
1. Operators are divided into
Arithmetic operator: Plus + minus-multiply * except/modulo%, where modulo operation% applies only to integers. Self-increasing operators, self-subtraction operators
Relational operators: >,<,>=, <=, ==,!= (by operator Precedence)
Logical operators:. , &&,| | ----result is true or false
Bitwise operators: Bitwise operators are specifically used for binary operations, divided into logical bitwise operators and SHIFT operators (<<.>>)
Assignment operators: =,+=,-=,*=,/=,%=,,&= (bitwise AND Assignment), |= (bitwise OR Assignment), ^= (bitwise XOR or Assignment), <<= left shift assignment, >>= right Shift assignment
Other operators: The three-wood operator (. :, (comma operator), sizeof operator, type conversion operator static_cast< destination type > (original data))
Bitwise operators:
1 Logical bitwise operators (as used for arithmetic operators): ~ (bitwise),& (Bitwise AND), | (bitwise OR), ^ (bitwise XOR)
and operations (and &): And operations are commonly used for binary fetch-bit operations, such as the result of a number and 1 is the lowest of the binary. This can be used to determine the parity of an integer, the lowest of the binary is 0, which means that the number is even, the lowest of 1 means the number is odd.
Bitwise OR (or |): The OR operation is typically used for unconditional assignment on binary positioning, for example, the result of a number or 1 is to force the lowest binary to 1. If you need to turn the binary down to 0, then subtract one after the number or 1, and the real meaning is to force the number to the nearest even.
XOR (^): An exclusive operation is usually used to reverse a particular one of the binary, because XOR can be defined as: 0 and 1 are invariant, or 0 are invariant, or 1 are reversed.
2 shift Operator: The value of the shift operator is also an arithmetic expression.
Move Left: 0
Move right: Complement sign bit
Three. Knowledge points about pointers
0. What information is stored by a pointer variable.
: The information that the pointer stores is the address of the object in memory. objects can be accessed indirectly through pointers
1. About what operations the pointer can perform.
:
1) Assignment operation. such as int a, *PA = &a,*q;p = Assignment operation of q;//pointer
2 pointer can add 1 operation or minus 1 operation
3 the pointer under certain conditions, can be subtracted (array case), point to the same array of different elements of two pointers can be subtracted, the difference is two pointers between the number of elements separated.
For example, in a string, let one point to the first element of the string, and the other to the Terminator, two pointers, the difference is the length of the string
4 The pointers can be compared with each other under certain conditions. For example, two pointers to the same array element can be compared, and when two pointers are equal, the same element that points to the array is indicated.
2. The most commonly used pointer type is what type of pointer. What is its role:
The most commonly used pointer type is char *, because in C + +, all string operations can be done through character pointers.
3. The relationship between pointer and array
: array elements can be represented by subscript, but preferably by pointers.
4. The relationship between array names and arrays of pointers.
: The array name is a constant pointer, and the array pointer is a variable pointer.
such as: int a[5],*p = A;
Expression p+1,p+2 is legal, and a+1,a+2 is illegal. Because the array pointer is a variable pointer, and the array name is a constant pointer
5. A pointer to a two-D array indicates:
6. Reference variables
: A reference is an alias to a variable, and a change to the reference is actually a change to the target.
Declaration form, int a = 3;
int &b = A;
7. The difference between references and pointers.
: The pointer accesses the variable indirectly through the address, and the reference is directly accessing the variable through the alias.
References must be initialized, and once initialized, they cannot be used as aliases for other variables.
The purpose of a reference is to be used as a function parameter.
4. in int a[5] = {1,3,5};, a[1]=
A.1 b.0 C.3 D.5
: The starting address for the C array is 0
5. In the character array initialization statement, the correct is
A.char s1[] = "ABCD"
B.char s2[3]= "xyz"//character array end symbol must have a.
C.char s3[][] ={a,b,c}
D.char S4[2][3] = {"xyz", "MNP"}
: A
6. in int a = 3,*p = &a, the value of *p is ()
A. Address value of variable a B. Meaningless C. Variable p address value D.3
: D---The pointer represents the address value, and the pointer's dereference represents the cell value of the address store
7. for int *pa[5]; the correct description is:
A.PA is a pointer to an array that points to an array of 5 int elements
B.PA is a pointer to the fifth element in an array, and the modifier is an int variable
C.PA[5] Represents the value of a fifth element of an array
D.PA is an array of pointers with five elements, and each element is a pointer.
: D, what do you mean by stating that this number is a type of number? The declaration of int *p[5] proves to be a pointer-type array that holds all pointers, such as int * p = &a; declares a pointer
8. With regard to the operation of the pointer, the wrong description is ()