The definition array in the 1.C language is in the form of a type array name [constant expression], which can include constants and symbolic constants, such as "int a[3+5"; is legal. Cannot contain variables, such as "int a[n];" is not legal. In other words, the C language does not allow the size of the array to be dynamically defined, that is, the size of the arrays does not depend on the value of variables during program run. If an array is defined in the called function (excluding the main function), the length can be either a variable or a non-amount expression. Such as:
void func (int n) { int a[2 * n]; Legal, n the value of the argument came ... }
When the Func function is called, the parameter n gets the value from the argument. This is called a variable-length array, allowing N to have different values each time the Func function is called. However, when the function is executed, the value of n is constant and the array length is fixed. If the specified array is statically stored, you cannot use a variable-length array. such as: static int a[2 * n]; is illegal.
If you specify the length of the array and initialize it when you define it, the system automatically initializes the array element to 0 if it is not specified by the initialization list, and if it is a character array, it is initialized to ' \ ' and if it is a pointer-type array, it is initialized to NULL, which is a null pointer.
Character array initialization method:
Char c[] = {"I am happy"}, equivalent to char c[] = "I am happy", the length of array c is not 10, but 11. Because the string constant is finally added by the system to a ' + '. The above initialization is equivalent to the following initialization. Char c[] = {' I ', ' ', ' a ', ' m ', ', ' h ', ' A ', ' P ', ' P ', ' Y ', ' n '}, and not equivalent to: char c[] = {' I ', ' ', ' a ', ' m ', ', ' h ', ' A ', ' P ', ' P ', ' Y '}; When using printf to output a character array, if you use the output of%s, you will stop the output if you encounter '/'.
The header file for the string handler function is String.h
2.strlen function--a function that measures the length of a string, and the value of the function is the actual length in the string (not including '% ').
3. Character array assignment can only be strcpy, string comparison takes strcmp (comparison dictionary order, lowercase letters greater than uppercase letters)
4.STRLWR function--a function converted to lowercase
5.STRUPR function--a function converted to uppercase
6. All functions are parallel, that is, functions cannot be nested defined. Functions can be called each other, but the main function cannot be called. The main function is called by the operating system. The data passing of an argument to a parameter is a "value pass", one-way pass, which can only be passed to the formal parameter by the argument, not to the argument by the parameter. Arguments and parameters have different storage units in memory, and arguments cannot get the values of formal parameters.
In a function declaration, the formal parameter name can be written without writing. The compilation system only cares about and examines the number of parameters and parameter types, not the parameter names, because the function is called only to ensure that the argument type is the same as the formal parameter type, regardless of the formal parameter name.
C Language Review 3/9