Article directory
Preface
A deep understanding of basic knowledge can help us use code flexibly.
1. Array
1. Definition of array
The definition of array is given in C language: a set of elements of the same type.
Example: int arr[10] = {1,2,3,4,5,6,7,8,9,10};//Define an integer array with a maximum of 10 elements.
2. Subscript of array
C language stipulates that each element of the array has a subscript, and the subscript starts from 0.
Arrays can be accessed through subscripts.
For example: int arr[10] = {0};
If the array has 10 elements, the subscript range is 0-9
3. Use of arrays
#include <stdio.h>
int main()
{
int i = 0;
int arr[10] = {1,2,3,4,5,6,7,8,9,10};
for(i=0; i<10; i++)
{
printf(“%d “, arr[i]);
}
printf(”\n”);
return 0;
}
2. Operator
Just a simple list
1. Arithmetic operators
++ - * / %
2. Shift operator
<< >>
3. Bit operators
& | ^
4. Assignment operator
= += -= *= /= &= ^= |= >>= <<=
5. Unary operator
! Logical inverse operation
- negative value
+ positive value
&Get address
Type length of sizeof operand (in bytes)
~Bitwise inversion of a number
– Prefix, Post-position –
++Pre-position, post-position++
Example: – Pre-position
Post-position – Post++
++Front
*Indirect access operator (operator for parsing)
(type) Forced type conversion
6. Relational operators
< <= > >= != (indicates inequality) == (indicates equality)
7. Logical operators
&&Logical AND (meaning AND)
||Logical OR (meaning OR)
8. Conditional operators
is also called the ternary operator, expressed as exp1?exp2:exp3
Example:
9. Comma expression
exp1,exp2,exp3,…expN
例:
10. Subscript references, function calls and structure members
[ ] (This is used for array subscript reference)
() (call function)
. Example:
->
Example: ->Equivalent to (*)