"C + +" C + + Learning Journey (4): Arrays and character arrays

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.