热门

最新

红包

立Flag

投票

同城

我的

发布
qq_54770463
修喵喵
4 年前
trueqq_54770463

比赛详情

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
C语言中第八章重定向有个程序用VS编写可能需要改一下,这是我编写的结果://打开文件并读取文件内容/*#include <stdio.h>#include <stdlib.h> // for exit()int main(){ int ch; FILE* fp; char fname[50]={0}; // to hold the file name printf("Enter the name of the file: "); scanf_s("%s", fname,50); fopen_s(&fp, fname, "r"); // open file for reading if (fp == NULL) // attempt failed { printf("Failed to open file. Bye\n"); exit(1); // quit program } // getc(fp) gets a character from the open file while ((ch = getc(fp)) != EOF) putchar(ch); fclose(fp); // close the file return 0;}
立即登录