1. When defining an array, the number of elements in the array cannot be dynamic and cannot be represented by a variable (the const variable can), which must be known.
2. Referencing an array can only refer to an element in the array and cannot refer to the entire array.
3. When a two-dimensional array is defined, the length of the first dimension can be omitted if all are initialized at the same time.
int a[][3]={1,2,3,4,5,6,7,8,9};
4. Array to do function parameters:
void haha (int array[],int n);
haha (a,10);
The value of the argument changes because the address is passed in.
5. Array of strings:
Char str[]= "Hello";
Char str[]={' h ', ' e ', ' l ', ' l ', ' o ', ' n '};
The above two are equivalent, not equivalent to the following
Char str[]={' h ', ' e ', ' l ', ' l ', ' o '};
The length of the two is different because the last element of the character array may not be '/' and will not be faulted.
6. String processing function, header file: string or String.h
strcat (Char[],const char[]);
strcat (STR1,STR2);
Add str2 to str1 tail, str2 remains unchanged, str1 becomes longer.
strcpy (Char[],const char[],int N);
strcpy (STR1,STR2);
strcpy (str1,str2,2);
Copy the str2 to str1, or copy the first 2 characters of str2 to str1.
strcmp (const char[],const char[]);
strcmp (STR1,STR2);
STR1=STR2, returns 0;
STR1>STR2, returns 1;
STR1<STR2, returns-1.
You cannot directly compare two STR because they are addresses.
strlen (const char[]);
Char str[]= "Hello";
strlen (str);
Returns the length of STR, no ' to ', and therefore 5.
7.string:
String str= "Sdsdsdsds";
string defines a normal variable instead of an array, can be arbitrarily assigned what, or can be used subscript, such as str[3] to access and can be modified, can be directly used with CIN, cout.
String can be directly "=", equivalent to strcpy;
String can be directly "+", equivalent to strcat;
String can be directly "<", ">", equivalent to strcmp;
vs2015, sizeof (string) = 28.
C + + arrays, strings, string