文件的字符串读写

windows vc6.0++通过。
功能:输入字符串,写入t.txt并显示在屏幕上

#include<stdio.h>
#include<string.h>
main()
{
    char str[80],str1[80];
    FILE *fp;
    if ((fp=fopen("t.txt","w+"))==NULL)
    {
        printf("Cannot open t.txt!\n");exit(1);
    }
    gets(str);
    fputs(str,fp);
    rewind(fp);
    fgets(str1,strlen(str)+1,fp);
    puts(str1);
    fclose(fp);
}

这里写图片描述
这里写图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42828324/article/details/81288648