Can you write a program that prints its own source code ( in C/C++ )? Of course it would be easy to do that referring to the source file, but how can this program be written assuming that the souce file is not available at run time?
:?: :?:
vicky_dev 12 Junior Poster in Training
Recommended Answers
Jump to PostSuch a program is known as a 'Quine' - see here for more info http://en.wikipedia.org/wiki/Quine_%28computing%29
Jump to PostIt can't.
It's proven that in any Turing-complete language you can create a program that writes its own code as output.
All 7 Replies
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
bala24 5 Junior Poster
Bench 212 Posting Pro
Salem commented: Beat me to it - Salem +4
John A 1,896 Vampirical Lurker Team Colleague
Rashakil Fol 978 Super Senior Demiposter Team Colleague
SpS commented: Yup +3
iamthwee
~s.o.s~ commented: :( -2
SpS 34 Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.