A file is a container in computer storage devices which is used for storing output or information permanently in the form of a sequence of bytes on the disk.
In C, you can perform various file handling operations like creating a file, deleting a file, opening a file, reading a file or you can even manipulate the data inside of a file. You can also work with the data in your program code by fetching it from a file. You can perform various file handling operations in C. In C, we can use file handling functions for various types of file manipulation like create, update, read or delete the files on the local file system. Below are the operations that you can perform on a file:-
Creating a new file.
Opening an existing file.
Reading from a file.
Writing to a file.
Deleting a file.
Assignment 1: Copy the one file from one location to another location using binary mode that is Binary File Handling
Binary File Handling is a process in which we create a file and store data in its original format. It means that if we stored an integer value in a binary file, the value will be treated as an integer rather than text.
Binary files are mainly used for storing records just as we store records in a database. It makes it easier to access or modify the records easily.
Hints:
#include<stdio.h>
#include<stdint.h>
int main()
{
FILE *input_file,*output_file;
input_file=fopen("XXXXX","rb");
output_file=fopen("YYYYY","wb");
int buffer;
while (!feof(input_file))
{
fread();
fwrite();
}
fclose(XXXX);
fclose(YYYYY);
printf("\n done\n");
return 0;
}