Posted by : Niraj lathiya Saturday 2 August 2014

C Program to Print its Own Source CodeEver wondered how to write a C program to print its own source code? Well, here is the source code of a C program that when executed will print its own source code. In other words, the output of this program is exactly same as its source code.



Here’s the program:

#include<stdio.h>
char *program=”#include<stdio.h>%cchar *program=%c%s%c;%cvoid main()%c{%cprintf(program,10,34,program,34,10, 10,10,10);%c}”;
void main()
{
printf(program,10,34,program,34,10,10,10,10);
}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Posts

Powered by Blogger.

- Copyright © Techno-World -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -