Ever wondered how to write a C program
that can print it’s own source code. Well, here is the source code of a C
program that when executed will print it’s own source code. In other
words, the output of this program is exactly same as it’s source code.
{
printf(program,10,34,program,34,10,10,10,10);
}
Here’s the program:
#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);
}