文件打开后 读入的是乱码 求大神支招!!!
程序代码:
#include<stdio.h> #include<stdlib.h> void main() { FILE *fp;int i,a[5];char filename[20]; scanf("%s",filename); fp=fopen(filename,"r+"); //fp=fopen("E:\\1.txt","r+"); if(fp==NULL) {printf("can't found the file\n");exit(0);} for(i=0;i<5;i++) { fread(a+i,sizeof(int),1,fp); printf(" a[i]=%d ",a[i]); } fclose(fp); }