C语言中如何将文件中的英语文章录入到一个字符数组中?

如题

#include<stdio.h>
#include<io.h>
#include<stdlib.h>

int main(){
FILE *fp=fopen("temp.txt","r"); //假定文件名为"temp.txt"
long fl;
char *p;
int h;
h=fileno(fp);
fl=filelength(h);
p=(char*)malloc(fl);
fread(p,1,fl,fp);
fclose(fp);
//... 此处对字符数组p进行处理。
free(fp);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
相似回答