Is it possible to write a code that prints 'its own code' when executed?
Just a thought.
adityats2020
0
Newbie Poster
Recommended Answers
Jump to Postjust copy paste the code into the quotes and add \n for line breaks
That will not print the code as it is, will it?
Define "as it is". If you meant as you typed then yes, it will. If however you meant the very code you wrote, I don't …
Jump to Post>>so no code can be regenerated once compiled?
No.
Jump to Post> Is it possible to write a code that prints 'its own code' when executed?
Yes, it's called a quine.
Jump to Post> it's limited to specific programs where programmers *intelligently* type in the same code in strings
Not always, but that is the most common method in the absence of reflection. The simplest C++ quine that Ed has come up with does not use that method.#include <fstream> …
Jump to Post> I beg to differ going by OPs comments:
Then we will differ. Ed does not want to get into a pointless argument. The OP can pick whichever answer is a better fit, and ask for clarification as necessary. ;)> I assume your program prints it's own code …
All 18 Replies
theABCasian
0
Light Poster
adityats2020
0
Newbie Poster
nbaztec
45
Posting Pro in Training
adityats2020
0
Newbie Poster
nbaztec
45
Posting Pro in Training
adityats2020
0
Newbie Poster
Taywin
312
Posting Virtuoso
Radical Edward
301
Posting Pro
jonsca
commented:
Nice
+4
Taywin
312
Posting Virtuoso
nbaztec
45
Posting Pro in Training
Radical Edward
301
Posting Pro
nbaztec
45
Posting Pro in Training
Radical Edward
301
Posting Pro
argio
0
Newbie Poster
Taywin
312
Posting Virtuoso
adityats2020
0
Newbie Poster
adityats2020
0
Newbie Poster
nbaztec
45
Posting Pro in Training
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.