Code for producing its own source code.

char*s=”char*s=%c%s%c;main( ) { printf ( s, 34, s, 34 ) ; }”;

main( ) { clrscr( ) ;printf ( s, 34, s, 34 ) ; }

This is a classic example of self-reproducing program. Program that produces its own source code as its output.

(ASCII of double-quote character has the value 34.)

The first s in printf( ) prints the string ‘char *s =’ , then due to %c within s it prints double-quote character and then %s within the string prints the whole string then due to %c it prints doube-quote(34) for the second time and lastly remaining part of string after %c gets printed out.

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers