#include <stdio.h>#include <stdlib.h>main(){int i,num[10];FILE *fr,*fw;if((fr=fopen ( "in.txt","r"))==NULL){printf("can't open file: in.txt\n");exit(0);}if((fw=fopen ( "out.bin","wb"))==NULL){printf("can't open file: res.dat\n");exit(0);}for(i=0;i<10;i++){fscanf(fr,"%d",&num[i]);}for(i=0;i<10;i++) fwrite(&num[i],sizeof(int),1,fw);fclose(fr);fclose(fw);}
讀文本用fscanf,二進(jìn)制些用fwrite,如果文本方式用fprintf么?
慕尼黑5688855
2022-11-19 13:09:25