C Program to Display same Source Code as Output

C Program to Display same Source Code as Output.


C Program t Disoplay same Source Code as Output Images-Pics-Photos-Snaps-Snapshots-Basic C Programs-Files in C-File Handling in C-File Operations in C-File Programs-C Language Programs-File Modes in C-General C Programs

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")


--------------------------------------------------------------------------------------------------------------------------

#include<stdio.h>
int main ( )
{
     FILE *fp;
     char ch;
     fp = fopen(_FILE_,"r");
     do
     {
           ch = getc(fp);
           putchar(ch);
     }
     while(ch ! = EOF);
     fclose(fp);
     return 0;
}

--------------------------------------------------------------------------------------------------------------------------

Output

--------------------------------------------------------------------------------------------------------------------------

$ cc program1.c
$ a.out



EmoticonEmoticon