#include<stdio.h> #include<stdlib.h> int main(void) { /*指向文件的指针*/ FILE* fp; char* str="hello world"; /*文件名称为text.txt,w代表以字符的方式写入 * wb是以二进制的方式写入*/ if((fp=fopen("text.txt","w"))==NULL) { printf("can not open file/n"); exit(1); } /*fputs是向文件中放入字符*/ fputs(str,fp); /*关闭文件*/ fclose(fp); return 0; }