SecureCRT Sample: Converting Deprecated CRT Functions to their _s Counterparts
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.
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 get samples and instructions for installing them:
On the Visual Studio Help menu, click Samples.
For more information, see Visual Studio Samples.
The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.
You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.
To build and run this sample
Open the solution file, SecureCRT.sln, in the Visual Studio development environment.
From the Build menu, click Build Solution.
From the Projects menu, click Properties.
Under Configuration Properties, select Debugging.
Specify the arguments to pass to the program in the Command Arguments text box ("if find.cpp" is a good first choice).
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.
This application can also be run from the command line: SecureCRT.exe if find.cpp