现在的位置: 首页 > 综合 > 正文

MSDN中关于fprintf()的注解

2013年08月05日 ⁄ 综合 ⁄ 共 558字 ⁄ 字号 评论关闭

// crt_fprintf.c
/* This program uses fprintf to format various
 * data and print it to the file named FPRINTF.OUT. It
 * then displays FPRINTF.OUT on the screen using the system
 * function to invoke the operating-system TYPE command.
 */

#include <stdio.h>
#include <process.h>

FILE *stream;

int main( void )
{
   int    i = 10;
   double fp = 1.5;
   char   s[] = "this is a string";
   char   c = '\n';

   fopen_s( &stream, "fprintf.out", "w" );
   fprintf( stream, "%s%c", s, c );//第一个表示输出流,stderr是一个标准错误输出流,第二个参数表示输出格式,第三个参数s,c等表示要输出的变量。
   fprintf( stream, "%d\n", i );
   fprintf( stream, "%f\n", fp );
   fclose( stream );
   system( "type fprintf.out" );
}

抱歉!评论已关闭.