zoukankan      html  css  js  c++  java
  • fwrite用法

    一:函数名: fwrite

      功 能: 写内容到流中

      用 法:fwrite(buffer,size,count,fp);

      (1)buffer:是一个指针,对fwrite来说,是要输出数据的地址。

      (2)size:要写入的字节数;

      (3)count:要进行写入size字节的数据项的个数;

      (4)fp:目标文件指针。

      程序例:

    1. #include <stdio.h>
    2.   struct mystruct
    3.   {
    4.   int i;
    5.   char ch;
    6.   };
    7.   int main(void)
    8.   {
    9.   FILE *stream;
    10.   struct mystruct s;
    11.   if ((stream = fopen("TEST.$$$", "wb")) == NULL) /* open file TEST.$$$ */
    12.   {
    13.   fprintf(stderr, "Cannot open output file. ");
    14.   return 1;
    15.   }
    16.   s.i = 0;
    17.   s.ch = 'A';
    18.   fwrite(&s, sizeof(s), 1, stream); /* write struct s to file */
    19.   fclose(stream); /* close file */
    20.   return 0;
    21.   }
  • 相关阅读:
    NSString 处理
    我的第一个IOSDemo
    NSArray创建和使用
    NSDate
    NSDictionary
    flash全屏代码
    getBounds
    运用递归随机出与上一个数不重复的数
    标签跟随鼠标移动
    保存数据到本地
  • 原文地址:https://www.cnblogs.com/mgstone/p/5829767.html
Copyright © 2011-2022 走看看