We recommend using Visual Studio 2017

RTC Sample: Run-Time Error Checks

The RTC sample shows how to use the C run-time library's run-time error check feature.

When you load this project into the development environment, you will notice two custom build configurations:


Does not use the C run-time library and, therefore, uses customized error reporting.


Uses the C run-time library and its error reporting mechanism.

Notice that the rtcsamp.cpp file contains the code that causes the bugs that are reported.

Security noteSecurity Note

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

To build and run this sample

  1. Open the solution rtcsample.sln.

  2. From the Build menu, click Build.

  3. From the Debug menu, select Start Without Debugging.

If you debug this project, you will see the Visual Studio debugger support for run-time error checks. That is, you will see the debugger's error reporting mechanism. The debugger's support for reporting run-time error checks is independent of whether you use the C run-time library.

For more information about run-time error checks, see the following topics:

This sample uses the following keywords:

_RTC_error_fn; _RTC_ErrorNumber; _crt_rtc_init; _rtc_geterrdesc; _rtc_initialize; _rtc_seterrorfunc; _rtc_terminate; catch_rtc_failure; defined; interlockedexchange; intrinsic; messagebox; sleep; sprintf_s; strcat_s; strcpy_s; va_arg; va_end; va_start; vsprintf_s; winmain