导航:首页 - 解读C语言中的3个标准文件(2)

解读C语言中的3个标准文件(2)
作者:深圳教育在线 来源:www.szedu.net 更新日期:2010-1-21

  stderr

  objectFILE * stderr;

  Standard error stream

  The standard error stream is the default destination for error messages and other diagnostic warnings. Like stdout, it is usually also directed to the output device of the standard console (generally, the screen)。

  stderr can be used as an argument for any function that expects an output stream as one of its parameters, like fputs or fprintf.

  Although generally both stdout and stderr are associated with the same console output, applications may differentiate between what is sent to stdout and what to stderrfor the case that one of them is redirected. For example, it is frequent to redirect the regular output of a console program (stdout) to a file while expecting the error messages to keep appearing in the console screen.

  It is also possible to redirect stderr to some other destination from within a program using the freopen function.

  perror

  functionvoid perror ( const char * str );

  Print error message

  Interprets the value of the global variable errno into a string and prints that string to stderr (standard error output stream, usually the screen), optionaly preceding it with the custom message specified in str.

  errno is an integral variable whose value describes the last error produced by a call to a library function. The error strings produced by perror depend on the developing platform and compiler.

  If the parameter str is not a null pointer, str is printed followed by a colon (:) and a space. Then, whether str was a null pointer or not, the generated error description is printed followed by a newline character ('\n')。

  perror should be called right after the error was produced, otherwise it can be overwritten in calls to other functions.

  Parameters.

  str

  C string containing a custom message to be printed before the error message itself.

  If it is a null pointer, no preceding custom message is printed, but the error message is printed anyway.

  By convention, the name of the application itself is generally used as parameter.


报 名 此 课 程 / 咨 询 相 关 信 息
【预约登门】 【网上咨询】 【订座试听】 【现在报名】
课程名称
解读C语言中的3个标准文件(2)
真实姓名
* 性 别
联系电话
* E-mail:
所在地区
咨询内容

      

相关文章:

Copyright© 2004-2017 www.szedu.net 深圳教育在线 版权所有
中国·深圳
粤ICP备06023013号