标签:无法 eof idt min bubuko fgetc ret width getch
#include "stdafx.h" #include <stdio.h> #include<Windows.h> int main() { char* filename=new char[1024]; filename = "E:\\下载文件\\vs2016\\first\\first\\mingwen.txt";//任意一个自己有该txt文件的路径 FILE *fp; if ((fp = fopen(filename, "r")) == NULL) { printf("无法打开此文件\n"); exit(0); } char *miwen = new char[1024]; int i = 0; while (!feof(fp)) { miwen[i++] = fgetc(fp); } //i--; miwen[i] = ‘\0‘; printf("%s",miwen); getchar(); return 0; }
在getchar();处加断点进行调试,得
#include "stdafx.h" #include <stdio.h> #include<Windows.h> int main() { char* filename=new char[1024]; filename = "E:\\下载文件\\vs2016\\first\\first\\mingwen.txt";//任意一个自己有该txt文件的路径 FILE *fp; if ((fp = fopen(filename, "r")) == NULL) { printf("无法打开此文件\n"); exit(0); } char *miwen = new char[1024]; int i = 0; while (!feof(fp)) { miwen[i++] = fgetc(fp); } i--; miwen[i] = ‘\0‘; printf("%s",miwen); getchar(); return 0; }
在getchar();处加断点进行调试,得
标签:无法 eof idt min bubuko fgetc ret width getch
原文地址:https://www.cnblogs.com/jakejian/p/9141298.html