Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

SecureCRT Sample: Converting Deprecated CRT Functions to their _s Counterparts 

Download sample

This sample demonstrates how to convert CRT functions which have been deprecated for security reasons to their _s counterparts. It covers the conversion of the following functions: strcpy, strncpy, fopen, _splitpath, sprintf, getenv, strcat, _creat, and itoa. It also demonstrates the use of _set_invalid_parameter_handler, another Secure CRT addition.

This sample implements the Boyer-Moore string matching algorithm using standard CRT functions.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To build and run this sample

  1. Open the solution file, SecureCRT.sln, in the Visual Studio development environment.

  2. From the Build menu, click Build Solution.

  3. From the Projects menu, click Properties.

  4. Under Configuration Properties, select Debugging.

  5. Specify the arguments to pass to the program in the Command Arguments text box (“if find.cpp” is a good first choice).

  6. From the Debug menu, click Start Without Debugging. The application will search each line of the file (find.cpp, in this case) for the text you specified (“if”) in the Command Arguments and write all matches to a file (find.cpp.match, in this case) in the working directory.

  7. This application can also be run from the command line: SecureCRT.exe if find.cpp

Keywords

strcpy_s, strncpy_s, fopen_s, _splitpath_s, sprintf_s, getenv_s, strcat_s, itoa_s, _set_invalid_parameter_handler

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft