1. Standard C language
The C language was born in the 1970s, older than ourselves, and produced many standards, but various compilers support different standards.
ANSI C is the most widely used standard and is also the first formal standard, known as "Standard C language". ANSI C was released in 1980 by the U.S. National Bureau of Standards (American Nation Standards Institute, abbreviation ANSI), the various compilers almost complete support ANSI C, books on the market, teaching materials in the university, Most of the tutorials on the Web are based on the ANSI C, and the C language Chinese network is no exception, and is based on ANSI C.
If you encounter other salutation, such as ISO C, C89, C90, Ansi/iso C, you should know that all refers to a version, the story of which please see: C language development and its version
2. Identifiers
The variable name, function name, label, etc. used in the program are collectively called identifiers. Except for the function name of the library function, which is defined by the system, the rest is customized by the user. In the C language, identifiers can only be strings consisting of letters (A~Z, a~z), Numbers (0~9), and underscores (_), and the first character must be a letter or an underscore.
The following identifiers are valid:
A, X, X3, Book_1, SUM5
The following identifiers are illegal:
3s starts with a number
Illegal characters appear in S*t *
-3x starts with a minus sign (-)
Bowy-1 illegal character minus sign (-)
The following points must also be noted when using identifiers:
- The standard C language does not limit the length of identifiers, but it is limited by the various versions of the C language compilation system and is also limited by specific machines. For example, the first eight bits of the specified identifier in a version C language are valid, and when the first eight bits of the two identifiers are the same, they are considered to be the same identifier.
- In identifiers, there is a difference in case capitalization. For example, book and book are two different identifiers.
- Although identifiers can be arbitrarily defined by programmers, identifiers are symbols used to identify a quantity. Therefore, the naming should have the corresponding significance, in order to facilitate the reading comprehension, as the "name implies".
3. Keywords
Keywords are strings that are specific to the C language and are often referred to as reserved words. User-defined identifiers should not be the same as keywords.
The C language keywords fall into the following categories:
| category |
Description |
| Type descriptor |
A type used to define, describe a variable, function, or other data structure. such as the int, double, etc. used in the previous example. |
| Statement-Definition character |
The function used to represent a statement. The If else used in example 1-3 is the statement definition of the conditional statement. |
| preprocessing command word |
Used to represent a preprocessing command. Include as used in the previous examples. |
4. Operators
The C language contains a fairly rich list of operators. Operators, together with variables and functions, form an expression that represents various arithmetic functions. An operator consists of one or more characters, such as a plus sign (+), a minus sign (-), a multiplication sign (*), and so on.
5. Separators
The delimiter used in C is separated by a comma (,) and a space. Commas are used primarily in the type description and function parameter tables, separating each variable. A space is used to make a spacer between the words of the statement. In the keyword, there must be more than one character space between identifiers, or there will be a syntax error, such as the int A; Written as Inta; The C language compiler treats Inta as an identifier, and the result is bound to go wrong.
6. Constants
Constants are the amount of values that cannot be changed. The constants used in C can be divided into numeric constants, character constants, string constants, symbolic constants, escape characters, and more. The introduction will be given in a later chapter.
7. Variables
Variables are named by the user to hold specific types of data, and the data can be changed. Data types are integers, floating-point numbers, characters, and so on, which are described in later chapters.
8. Notes
The standard C language comment is a string that begins with "/*" and ends with "*/". The comment is between "/*" and "/*". When the program compiles, no comments are processed. Comments can appear anywhere in the program. Comments are used to prompt or explain the meaning of the program to the user. Statements that are not used in the debugger can also be enclosed in annotations so that the translation is skipped and the comment is removed after the debug is finished.
In addition, various compilers support comments beginning with "//", although it is not a standard C, but it is already a fact standard and is widely used in programs. "//" only supports single-line comments, that is, line breaks are not allowed in comments, and "/* * * * *" supports multiple lines of comments, and newline characters can appear in comments.
Basic concepts of C language