错误处理 (CRT)Error Handling (CRT)

使用这些例程处理程序错误。Use these routines to handle program errors.

错误处理例程Error-Handling Routines

例程Routine 使用Use
assertassert macro 测试编程逻辑错误;在运行时库的发行版和调试版中可用。Test for programming logic errors; available in both the release and debug versions of the run-time library.
_ASSERT、_ASSERTE_ASSERT, _ASSERTE macros 类似于 assert,但仅在运行时库的调试版本中可用。Similar to assert, but only available in the debug versions of the run-time library.
clearerrclearerr 重置错误指示器。Reset error indicator. 调用 rewind 或关闭流也会重置错误指示器。Calling rewind or closing a stream also resets the error indicator.
_eof_eof 检查底层 I/O 的文件尾。Check for end of file in low-level I/O.
feoffeof 测试文件尾。Test for end of file. _read 返回 0 时,也指示文件尾。End of file is also indicated when _read returns 0.
ferrorferror 测试流 I/O 错误。Test for stream I/O errors.
_RPT、_RPTF_RPT, _RPTF macros 生成类似于 printf 的报告,但仅在运行时库的调试版本中可用。Generate a report similar to printf, but only available in the debug versions of the run-time library.
_set_error_mode_set_error_mode 修改 __error_mode 来确定非默认位置,其中,C 运行时为可能导致程序关闭的错误编写错误消息。Modifies __error_mode to determine a non-default location where the C run time writes an error message for an error that will possibly end the program.
_set_purecall_handler_set_purecall_handler 为纯虚函数调用设置处理程序。Sets the handler for a pure virtual function call.

另请参阅See Also

按类别分的运行时例程Run-Time Routines by Category