The array aspect is basically the same as C. Several points to note are as follows:
One, multidimensional arrays
In addition to one-dimensional arrays, two-dimensional arrays, of course, can also implement multidimensional arrays (n-dimensional can), the definition and use of the analogy of two-dimensional arrays. A multidimensional array is actually a nesting of many one-dimensional arrays, with arrays inside them.
Two, character array
An array of characters is an array of characters for the array element, but it is worth mentioning that it can be used as a string. C + + still does not have a string variable , and in fact, string is not the basic type that the C + + language itself has, it is a string class declared in the C + + standard library, where objects can be defined with such a class. Each string variable is an object of the string class.
One Chinese character accounts for 2B.
Three, character function review
defined in <cstring> or <string.h>.
Function |
Function |
strcpy (TARGETSTR,SOURCESTR) |
Copy |
strncpy (Targetstr,sourcestr,limit) |
Copy, up to a limit character |
strcat (TARGETSTR,SOURCESTR) |
Connection |
Strncat (Targetstr,sourcestr,limit) |
connections, up to limit characters |
Strlen (SOURCESTR) |
Returns the integer value of the string length |
strcmp (STR1,STR2) |
Compare, greater than return a positive number, equal to return 0, less than return negative |
STRNCMP (Str1,str2,limit) |
comparison, up to a limit of characters |
"C + +" C + + Learning Journey (4): Arrays and character arrays