c语言基础:char写入一个文件
#include <stdio.h> #include <string.h> int write_change_policy(const char* filename,char* buf_policy) { FILE *fp = NULL; fp = fopen(filename,"w+"); if(!fp){ return -1; } if(fwrite(buf_policy,1,strlen(buf_policy),fp) < 0){ return -1; fclose(fp); } fclose(fp); return 0; } int main() { char paht[256]; strcpy(paht,"dsfdfsdfsdf"); write_change_policy("abc.txt",paht); system("ls"); return 0; }
浙公网安备 33010602011771号