Question :- C Program to Display its own Source Code as its Output
Here is source code of the C Program to display its own source code as its output. We have used low-level file handling to achieve this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
/* C Program to Display its own Source Code as its Output */ #include <stdio.h> int main() { FILE *fp; char ch; fp = fopen(__FILE__,"r"); while (ch != EOF) { ch = getc(fp); putchar(ch); } fclose(fp); return 0; } |