C语言fprintf和fputs文件写,文件指针往下偏移

#include "main.h"
#include <stdio.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    short buf[480] = {0};
    int ret = -1;
    FILE* pwav = fopen("mymic.wav","wb"); // wb打开有会自动删除
    if( pwav== NULL)
    {
       printf("pwav is NULL\n");
    }
    memset(buf,1,960);
   // sprintf(buf,"hello"); // strcpy和sprintf都可以
    strcpy((char*)buf,"world");
    //size_t ret = fwrite(buf,480*2,1,pwav);
    fprintf(pwav,"%s\n","hello");  // \n
    fprintf(pwav,"%s\n","mygirl"); // \n
    printf("ret is %d\n",ret);
    fputs("www.baidu.com\n",pwav); // \0 和 \n
    fputs("2020/9/18\n",pwav);
    fflush(pwav); // 没有fflush 文件里面什么都没有
    getchar();
    fclose(pwav);
    for(;;);
    return 0;
}

  

posted @ 2020-09-18 10:24  卷哭你  阅读(550)  评论(0编辑  收藏  举报