TUTORIALS

C Program to display the same source code on terminal

Written By: Chaitra M
Created at: 28-June-2023 20:36:19
Modified at: 28-June-2023 20:36:39

Program


#include<stdio.h>
 
void main()
{
	FILE *fp;
	char ch;
 
	fp = fopen(__FILE__, "r");
 
	do
	{
		ch = getc(fp);
		putchar(ch);
	}while (ch != EOF);
	fclose(fp);
	printf("\n");
}

Output


#include<stdio.h>
 
void main()
{
	FILE *fp;
	char ch;
 
	fp = fopen(__FILE__, "r");
 
	do
	{
		ch = getc(fp);
		putchar(ch);
	}while (ch != EOF);
	fclose(fp);
	printf("\n");
}

There are no likes. Be the first one to like
Likes: 0
Comments: 0