static
1 Inside a function, retains its value between calls;
2 At the function level, visible only in this file.
The multiplication operator
Applied to a pointer, indirection;
In a declaration, a pointer.
Using pointers for ragged arrays.
C-style string is used in windows API, because there is no c++ at that time.
To C-style string, a string object both more convenient and safer than using an array. Conceptually, one thinks of an array of char as a collection of char storage units used to store a string but of a string class variable as a single entity representing the string.
Like a composition, an aggregation is still a part-whole relationship, where the parts are contained within the whole, and it is a unidirectional relationship. However, unlike a composition, parts can belong to more than one object at a time, and the whole object is not responsible for the existence and lifespan of the parts. When an aggregation is created, the aggregation is not responsible for creating the parts. When an aggregation is destroyed, the aggregation is not responsible for destroying the parts.
A literal constant is a fixed value inserted directly into the source code. Examples are 5 and “Hello world!”.
A definition actually implements (for functions or types) or instantiates (for variables) the identifier. Here are some examples of definitions:
int add(int x, int y) // implements function add() { int z{ x + y }; // instantiates variable z return z; }
A definition is needed to satisfy the linker. If you use an identifier without providing a definition, the linker will error.
A declaration is a statement that tells the compiler about the existence of an identifier and its type information. Here are some examples of declarations:
int add(int x, int y); // tells the compiler about a function named "add" // that takes two int parameters and returns an int. No body! int x; // tells the compiler about an integer variable named x
A declaration is all that is needed to satisfy the compiler. This is why we can use a forward declaration to tell the compiler about an identifier that isn’t actually defined until later.
解引用:解除引用得到值;
printf()使用转义字符和变量点位符。
In programming, a constant is a fixed value that may not be changed. C++ has two kinds of constants: literal constants, and symbolic constants.
A block of statements, also called a compound statement, is a group of statements that is treated by the compiler as if it were a single statement. Blocks begin with a { symbol, end with a } symbol, and the statements to be executed are placed in between. Blocks can be used any place where a single statement is allowed. No semicolon is needed at the end of a block.
Local variables have block scope (also called local scope), which means they enter scope at the point of declaration and go out of scope at the end of the block that they are defined in.
typedef char*(*pf)(int i);
typedef pf pfa;
Any statement can be labeled, by providing a name followed by a colon before the statement itself.
identifier : statement (1)
case constant_expression : statement (2)
default : statement (3)
1) Target for goto.
2) Case label in a switch statement.
3) Default label in a switch statement.
Each character stored in the string may occupy more than one byte. The encoding used to represent characters in a multibyte character string is locale-specific: it may be UTF-8, GB18030, EUC-JP, Shift-JIS, etc. For example, the char array {'\xe4','\xbd','\xa0','\xe5','\xa5','\xbd','\0'} is an NTMBS holding the string "你好" in UTF-8 multibyte encoding: the first three bytes encode the character 你, the next three bytes encode the character 好. The same string encoded in GB18030 is the char array {'\xc4', '\xe3', '\xba', '\xc3', '\0'}, where each of the two characters is encoded as a two-byte sequence.
setlocale(LC_ALL, "zh_CN.UTF-8");
char cn[]={'\xc4', '\xe3', '\xba', '\xc3', '\0'}; // 你好,大于128的编码,BG2312