After specifying _CRTDBG_MODE_FILE with _CrtSetReportMode, you can specify the file handle to receive the message text. _CrtDbgReport also use _CrtSetReportFile to specify the text destination (debug version only).
int _CrtSetReportFile (
    int reportType, 
    int reportFile 
);
reportType 
_CRT_WARN
_CRT_ERROR
_CRT_ASSERT 
reportFile 
reportType. You use _CrtSetReportFile with _CrtSetReportMode to define the destination(s) for a specific report type generated by _CrtDbgReport. When _CrtSetReportMode is called to assign the _CRTDBG_MODE_FILE reporting mode for a specific report type, _CrtSetReportFile should then be called to define the specific file or stream to use as the destination. When _DEBUG is not defined, preprocessing removes calls to _CrtSetReportFile.
The following lists available choices for reportFile and the resulting behavior of _CrtDbgReport. These options are defined as bit flags in crtdbg.h.
file handle 
_CRTDBG_FILE_STDERR 
_CRTDBG_FILE_STDOUT 
_CRTDBG_REPORT_FILE 
The report file used by each report type can be separately controlled. For example, you can send a reportType of _CRT_ERROR to stderr, while sending a reportType of _CRT_ASSERT to a user-defined file handle or stream.
On successful completion, _CrtSetReportFile returns the previous report file defined for the report type specified in reportFile.
| Versions | Defined in | Include | Link to | 
|---|---|---|---|
| INtime 3.13 | intime/rt/include/crtdbg.h | crtdbg.h | clib.lib |