C + + for security versions of functions such as strcpy

Source: Internet
Author: User

The following programs:

#include <iostream>usingnamespace  std; int Main () {     char ch1[];    strcpy (CH1,"123456");}

Error when compiling on VS2012:

Error C4996: ' strcpy ': This function or variable could be unsafe. Consider using strcpy_s instead.

In VS2010, there are numerous system function names appended with _s, such as scanf_s (), strcmp_s (), and so on. _s that this method is safe (safe), the original function on the length of the string is ignored, may overflow, these add _s method to determine the length, if the target character can not be copied.

That's why the _s security version appears.

C + + for security versions of functions such as strcpy

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.