c语言向文件中写入

创建一个文件使用fopen打开,然后使用fprintf输出,最后关闭文件流

FILE *out;
out = fopen("test.txt","a+");
if(out == NULL){
        exit(EXIT_FAILURE);
}
printf("hello~\n");
int i;
for(i=0;i<10;i++){
    fprintf(out,"heelo %d\n",i);
}
fclose(out);

 

posted @ 2014-03-26 19:24  xingoo  阅读(947)  评论(0编辑  收藏  举报