Home Forums C Programming C program to display own source code as output Reply To: C program to display own source code as output

#3277
Rashmi singh
Participant
#include
main()
{
FILE *fp;
char ch;
fp=fopen("file_display.c","r"); //here 'file_display.c' may differ
//reads char by char and stores it in 'ch' until the End of File
while((ch=getc(fp))!=EOF)
{
 putchar(ch);
}
fclose(fp);
}