C语言 简单的文件操作 写文件

#include <stdio.h>

#define BUFSIZE 50

int main()
{
    FILE* f;
    char buf[BUFSIZE] = "this is fputs function!\n hello fputs!";
    
    f=fopen("D:\\1.txt","w");
    
    if(NULL == f)
    {
        printf("write file failed!");
    }
    
    fputs(buf,f);
    
    fclose(f);
}

 

posted @ 2022-01-14 10:21  晓风霜度-  阅读(233)  评论(0)    收藏  举报