C Program to Display same Source Code as Output.
A File represents a sequence of bytes on the disk where a group of related data is stored. File is created for permanent storage of data. There are 2 types of files.
1. Text files
2. Binary files
1. Text files
Text files are the normal .txt files that you can easily create using Notepad or any simple text editors.When you open those files, you'll see all the contents within the file as plain text. You can easily edit or delete the contents.
2. Binary files
Binary files are mostly the .bin files in your computer. Instead of storing data in plain text, they store it in the binary form (0's and 1's). They can hold higher amount of data, are not readable easily and provides a better security than text files.
File OperationsIn C, you can perform 4 major operations on the file, either text or binary:
⦁ Creating a new file
⦁ Opening an existing file
⦁ Closing a file
⦁ Reading from and writing information to a file
When working with files, we need to declare a pointer of type file. This declaration is needed for communication between the file and program.
FILE *fptr;
Opening a file is performed using the library function in the "stdio.h" header file: fopen( )
The syntax for opening a file in standard I/O is
ptr = fopen("fileopen","mode")
--------------------------------------------------------------------------------------------------------------------------
EmoticonEmoticon