Program to print its own Source Code

Here is a C program to print its own source code. This code will print its source. The output of this program will be exactly similar to its source code. Here is the code...

#include
char *program=”#include%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);
}


If you are having any trouble in compiling the source code then take a look here How to Compile a C Program.
Previous
Next Post »