Q:

C program to write an array in a file using the fwrite

0

C program to write an array in a file using the fwrite

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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;
}

Output:

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now