Home » C » C Program
The logic to print the program itself is to read the same file in which we have saved our program.
//assume the file name is print_program.c
#include <stdio.h>
int main(int argc, char *argv[]) {
FILE* file = fopen("print_program.c", "r");
char line[200];
while (fgets(line, sizeof(line), file)) {
printf("\n%s", line);
}
fclose(file);
return 0;
}