Tuesday, July 28, 2009

Write a C Program to produce its own source code as output.?

char*f="char*f=%c%s%c;main()


{printf(f,34,f,34,10);}%c";


main(){printf(f,34,f,34,10);}

Write a C Program to produce its own source code as output.?
dear,


this question applies even when source file is deleted


and yes there is only 1st option available.





2nd one is too easy though.





yes it is a loop kind of bit obscure code.


i once found on net.


dont remember though.
Reply:It's been done.


Look on the web.


Two options: Either you have to have a loop so it can print it's own sourcecode twice without actually including it twice.


The other option was cheating: A program that read and printed its own sourcefile. I liked that one for thinking outside the box :)
Reply:u have to type more than 50 lines.bcoz its the task of assembler that is in 1st pass it generate souce code along with symbol table.just refer any 3rd sem computer science engg student.bcoz they have the subject system software and they also has corresponding lab their 1st expriment is this.try in this way
Reply:You can try compiling and running the following C program...


No comments:

Post a Comment