以附加方式打开文件,输入数据,关闭文件。

#include<stdio.h>
#include<stdlib.h>
int main()
{
        FILE *fp = NULL;
        fp = fopen("test.txt","a+");
        if(fp == NULL)
        {
                printf("cannot open file");
                return -1;
        }
        char c[]="22.33,42";
        char d[] = {'2','3','.','1','4',',','4','1'};
        fprintf(fp, "%s\n",c);
        fprintf(fp,"%s\n",d);
        fclose(fp);
        fp = NULL;
        return 0;

}

 

 posted on 2015-09-06 11:04  十三弦  阅读(182)  评论(0编辑  收藏  举报