文件与流 -- fopen/fclose
#include <stdio.h> int main(void) { FILE* fp = NULL; fp = fopen("abc.txt","a+"); //fopen(path, mode) 以“mode”的方式打来文件abc.txt if (NULL == fp) { printf("fopen fail\r\n"); perror(""); } else { fwrite("hello filestream!", 1, 17, fp); //fwrite(const char* string, size_t size, size_t nmem, fp)将string指向的字符串写到fp指向的文件中,单个写入内容大小为size,总共nmem个size大写的内容写入 fclose(fp); } return 0; } 来源: 51CTO 作者: tresordie 链接: https://blog.51cto.com/4265810/2068688