// Check size of file using wc command //$ wc wf.txt //$ wc wf.bin #include #include int main(){ int i; int A[10]; //use any data type int, float, int int B[20]; // use any data type, int, float, int FILE *fp; for(i=0;i<10;i++) A[i]=rand()/100.0; fp=fopen("wf.txt","w"); //Writing to text file for(i=0;i<10;i++) fprintf(fp, "%s ", A[i]); fclose(fp); fp=fopen("wf.bin","wb"); //Writing to bin file fwrite(A, sizeof(int), 10, fp); fclose(fp); fp=fopen("wf.bin","rb"); //reading from bin file fread(B, sizeof(int), 10, fp); for(i=0;i<10;i++) printf("%lf ",B[i]); //Verify read data fclose(fp); return 0; }