c++--Key Review

Source: Internet
Author: User

1. Thestrlen function always assumes that its argument string ends with NULL, and that if the string does not end with NULL, the result of the calculation will not be predictable.

2. Multiple expressions can be separated by commas , the values of each expression are computed separately , but the value of the entire expression is the value of the last expression .

3. After converting a two-dimensional array into a one-dimensional array, the two-dimensional array element a[x][y] = b[x * Number of columns + y], where B is the transformed one-dimensional array.

4. The pointer array is an array of pointers, defined as: int *a[10], and The array pointer is a pointer to an array, defined as: int (*a) [10].

5. In the C language, the array is used as the parameter of the function and always raises the decay (decay) problem, missing the length information of the array .

6. Sequential table Insert algorithm, delete algorithm, find algorithm average time complexity is O (n).

7. A substring is a subsequence of any contiguous character in a string, and specifies that an empty string is a substring of any string, and that the subsequence does not require consecutive characters, but that the order is consistent with the main string.

Some differences between 8.strcpy and memcpy:

1) Different content is copied, strcpy can only copy the string, memcpy can copy any content. strcpy is used only for string copying, and it copies the Terminator of the string, not only the contents of the string. The memcpy has no limitations on what needs to be replicated and is therefore more widely used.

2) The method of copying is different. strcpy does not need to specify the length, it encounters the string terminator of the copied character ' \ s ' before it ends, so it is prone to overflow. The memcpy, in other words, determines the length of the copy based on the third parameter.

3) different use. memcpy is typically used when copying strings with strcpy and when other types of data need to be copied.

9. In a string pattern match, the time complexity of the BF algorithm (the most basic algorithm) is O ((m-n + 1) * N), while the time complexity of the KMP algorithm is O (M + N). (where m, n represents the length of the main string and the substring).

10.

c++--Key Review

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.