C Program which prints itself

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


return 0;

Output of the Program

C program which print itself


About Us | Contact Us | Privacy Policy | Career  | Online Training
Youtube   LinkedIn   Facebook   Twitter   Instagram  
Like many websites, we use cookies to ensure best browsing experience on our website. While using this website, you acknowledge to have read and accepted our cookie and privacy policy.