Why does the C language not check array subscript for out-of-bounds?

Source: Internet
Author: User

1. In order to improve the running efficiency, do not check if the array table is out of bounds,ProgramYou can run fast. Because C language is not a fast development language, it requires developers to ensure that all logic is correct. Therefore, at least till now, C language is the fastest and most efficient among all advanced languages. The C language is used for almost all scenarios with demanding performance requirements.

2. The subscript is not checked for greater space and convenience for pointer operations. If this check is available, the pointer function will be greatly weakened. The array identifier of C does not contain information about the length of the array, but only the address information. Therefore, the language itself cannot be checked, it can only be checked by the compiler, and the early C language compiler does not check the array out of bounds. It can only be checked by the programmer. In addition, in early CRT functions, cross-border checks on string pointers or arrays were not performed. programmers were required to ensure sufficient space, therefore, it was only after vs2005 that Microsoft provided a secure CRT function version.

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.