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 PostYour code will not look like a code as you see once compile because it will be turned into machine code which could be varied depending on what compiler you use. The reason is that a compiler has its own code optimization algorithm and that could change the result after …
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 …
Jump to PostI know a way but it'd be goofy I did it for one of my homework assignments.
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.