fputc的使用

#include "stdafx.h"
#include <stdio.h>
#include<stdlib.h>
int main()
{
    FILE *fp;
    char ch;
    char *str = "www.cskaoyan.com";
    if(fopen_s(&fp,"ReadMe.txt","at+") != NULL)
    {
        printf_s("文件打开失败\n");
        getchar();
        exit(1);
    }
    else
    {
        fputs(str,fp);
        rewind(fp);
        ch =fgetc(fp);
        while(ch != EOF)
        {
            putchar(ch);
            ch = fgetc(fp);
        }
        printf_s("\n");
        int id = fclose(fp);
        if(id == 0)
        {
            printf_s("关闭成功") ;
        }
        else
            printf_s("关闭失败");

    }
    return 0;

}

 

posted @ 2015-04-17 15:39  码农@163  阅读(213)  评论(0编辑  收藏  举报