WRITING OF ENTIRE ARRAY TO A FILE USING C PROGRAM





Writing of entire array to a file using c program


#include<stdio.h>
int main(){
  FILE *p;
  int i,a[10];
  if((p=fopen("myfile.dat","wb"))==NULL){
      printf("\nUnable to open file myfile.dat");
      exit(1);
  }
  printf("\nEnter ten values, one value on each line\n");
  for(i=0;i<10;i++)
      scanf("%d",&a[i]);
  fwrite(a,sizeof(a),1,p);
  fclose(p);
  return 0;
}





2.  Write a c program to delete a file.
3. Write a c program to copy a file from one location to other location.
6. Write a c program which writes string in the file.

6 comments:

Tai Christian said...

Thank you! Could you show me how to generate an array from myfile.dat, please?

Anonymous said...

Thanks a lot!

Unknown said...

can u tell us the program to print some rows and columns from the file.

Prateek Meshram said...

and if u do it please mail me on "prateekmeshram100@gmail.com"

Prateek Meshram said...

and if u do it please mail me on "prateekmeshram100@gmail.com"

Prateek Meshram said...

can u tell us the program to print some rows and columns from the file.