您的位置:首页 > 编程语言 > C语言/C++

MSDN中关于fprintf()的注解

2013-07-13 18:04 120 查看
// 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" );

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C++ fprintf 输出输入