V
vinay.khankari
How to Print the complete source program as output of the program?
How to Print the complete source program as output of the program?
Victor Bazarov said:Please google for "self-printing program".
It is a fun problem to solve, but IIRC, it doesn't have
any portable solution.
Pavel said:Or, better yet, "quine".
Why not? What am I missing? Some of the C++ quines I've
found in a couple of minutes of googling (e.g., a David
Rogers' one on Gary Thompson's page) seem to be easily
adapted to be standard-compliant and reasonably portable.
Victor said:Most of them involve ASCII coding. That's not portable.
How many systems can you mention which are used today and which
do not use ASCII coding?
Heck, *no* C++ source code is portable to systems which do not
use ASCII coding because the source code itself uses ASCII coding.
Juha Nieminen said:How many systems can you mention which are used today and which
do not use ASCII coding?
Heck, *no* C++ source code is portable to systems which do not
use ASCII coding because the source code itself uses ASCII coding.
Please google for "self-printing program". It is a fun problem to
solve, but IIRC, it doesn't have any portable solution.
Most of them involve ASCII coding. That's not portable.
I believe that IBM still uses EBCDIC on their z series machines.
Not unless it's not written on a machine which uses ASCII, besides I
don't think the C++ standard defines how the source should be encoded,
only which characters that can be expected to be recognised.
Bo said:The "ascii" command tells the ftp processors (one at each end!) that
the *transfer* is done in text mode. It doesn't tell anything about
how the file is encoded at either end. At the Z-series end, the ftp
processor will translate "ascii" mode transfers to/from EBCDIC, when
communicating with a non-EBCDIC device.
This means that source code actually IS portable between ASCII and
EBCDIC, if you just transfer it properly.
Erik said:I believe that IBM still uses EBCDIC on their z series machines.
Bo said:No, but you might need it to transfer your program to the mainframe.
It doesn't support floppies or USB-memories, and the operators won't
let you get even close to the CD-reader.
You could also use a terminal, and type it in again.![]()
That's just ridiculous. I need an FTP program in order to compile
some source code?
Of course this raises the question of why you would even want to
run a self-printing program in a mainframe...![]()
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.