C language-basic syntax and C language syntax
First, I learned the basic syntax of C language, mainly including keywords, identifiers, comments, data, constants, and variables.
I. Keywords
1 keyword refers to the default special characters in C language.
2 The keywords are all lowercase letters, and a total of 32 keywords (int and return in main function [main]) are as follows:
auto double int struct break else long switchcase enum register typedef char extern return unionconst float short unsigned continue for signed voiddefault goto sizeof volatile do if while static
Ii. identifier
1 identifier is also a special character. It is a programmer-defined name and symbol (the keyword is the default in C language ).
2. The role of the identifier.
(1) name variables to distinguish different variables.
(2) function naming for easy Differentiation
3. custom name of the identifier
(1) Basic Principles
① It can only consist of 26 English letters (case sensitive), 10 Arabic numerals (0-9), and underscores (_).
② It cannot start with a number
③ The built-in keywords cannot be used.
(2) improved specifications
① Try to use English words. Or chinese.
② When an identifier is composed of multiple letters, the first word is separated and the first letter of each word is capitalized.
3. Notes
1. Annotations are used to explain the meaning of a line or code program. They do not participate in program compilation or increase the code size.
2 single line comment
A single line comment starts with two forward slashes (//). Only one line can be commented. The comment content starts from // and ends with the end of this line.
3 multi-line comment
Multi-line comments start with/* and end with */. The content in the middle of/* and */is both comments.
Iv. Data (static and dynamic)
1. Static Data
If you do not manually delete the data, the data is stored in the hard disk of your computer. It generally exists as a file.
2. Dynamic Data
The temporary data (dynamic data) is automatically deleted when the computer is disabled.
3. Static and Dynamic Data can be converted to each other under certain conditions.
4. Data unit size conversion
1 KB = 1024 B, 1 MB = 1024 KB, 1 GB = 1024 MB, 1 TB = 1024 GB
5. constants (fixed data)
Category
1 integer constant (int), containing all Integers
2 float Type constants (float/double), float: Single-precision float type; double-precision float type
A three-character constant (char), a single character enclosed in single quotes, except for Chinese characters.
4 string constants, one or more characters enclosed in double quotes, except for Chinese characters.
Vi. variables (data that needs to be changed in due time)
1. The variable must be defined first, and a memory will be allocated.
2. Variable Definition Format: variable name of the variable type (for example, int I ;)
3 variable assignment: variable name = value (for example, I = 1 ;)
4. The modification of the variable value overwrites the value before the variable name.