Below code writes the entire integer array into the file.
#include <stdio.h>
int main()
{
//Variable which want to write
int data[] = {65,66,67,68,69};
//file pointer
FILE *fp = NULL;
//create and open the text file
fp = fopen("aticleworld.dat", "wb");
if(fp == NULL)
{
printf("Error in creating the file\n");
exit(1);
}
//write the array in file
fwrite(data, sizeof(data),1, fp);
fclose(fp);
return 0;
}
Below code writes the entire integer array into the file.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer