fprintf_fscan讲述.docxVIP

  • 9
  • 0
  • 约6.44千字
  • 约 10页
  • 2017-05-04 发布于湖北
  • 举报
fprintf_fscan讲述

对文件的读和写是最常用的文件操作。在C语言中提供了多种文件读写的函数: ·字符读写函数 :fgetc和fputc ·字符串读写函数:fgets和fputs ·数据块读写函数:fread和fwrite ·格式化读写函数:fscanf和fprinf 随着每次数据的读取,文件流指针fp都作相应的移动 使用以上函数都要求包含头文件stdio.h。例子都来自msdn 1 fprintf——Print formatted data to a stream #include stdio.h #include process.h FILE *stream; void main( void ) { ? int??? i = 10; ? double fp = 1.5; ? char?? s[] = this is a string; ? char?? c = \n; ? stream = fopen( fprintf.out, w ); ? fprintf( stream, %s%c, s, c ); ? fprintf( stream, %d\n, i ); ? fprintf( stream, %f\n, fp ); ? fclose( stream ); ? system( type fprintf.out ); } Output this is a string 10 1.

文档评论(0)

1亿VIP精品文档

相关文档