C program which writes array in the file.

source code


#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);
 getch();
  return 0;
}

Comments

Popular posts from this blog

8086 STRING MANIPULATION –FIND AND REPLACE A WORD

Animated Circles In C++

C program to find out the sum of series 1 + 2 + …. + n.