Below code writes the value of integer variable data into the file.
#include <stdio.h>
int main()
{
//Variable which want to write
int data = 65;
//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 variable in file
fwrite(&data, sizeof(data), 1, fp);
fclose(fp);
return 0;
}
Below code writes the value of integer variable data into the file.
need an explanation for this answer? contact us directly to get an explanation for this answer