5
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by ArkM
Featured Replies
  • 1

    That is no fun comatose!!!! The program should write itself without reference to the source code!!! You want to look up quine e.g.[URL="http://prokutfaq.byethost15.com/Cquine"]http://prokutfaq.byethost15.com/Cquine[/URL] I distinctly remember the first time I saw a quine program,. fortran-77 -- I am getting old :) -- and I was very happy when I finally … Read More

  • 1
    ArkM 1,090   8 Years Ago

    [QUOTE=Comatose;800389]Show me the code you have, and I can see what help I can offer once I see what effort you have applied. Step 1. Read argv[0]. argv[0] is the name of the file Step 2. Check that argv[0] file still exists (yeah, it should) step 3. Open the file … Read More

0

Show me the code you have, and I can see what help I can offer once I see what effort you have applied.

Step 1. Read argv[0]. argv[0] is the name of the file
Step 2. Check that argv[0] file still exists (yeah, it should)
step 3. Open the file pointed at by argv[0]
step 4. Read the file, and display it to the screen.
step 5. Close the file, and end the program.

1

That is no fun comatose!!!! The program should write itself without reference to the source code!!!

You want to look up quine

e.g.http://prokutfaq.byethost15.com/Cquine

I distinctly remember the first time I saw a quine program,. fortran-77 -- I am getting old :) -- and I was very happy when I finally groked it.

Comments
:)
1

Show me the code you have, and I can see what help I can offer once I see what effort you have applied.

Step 1. Read argv[0]. argv[0] is the name of the file
Step 2. Check that argv[0] file still exists (yeah, it should)
step 3. Open the file pointed at by argv[0]
step 4. Read the file, and display it to the screen.
step 5. Close the file, and end the program.

Yes, it's a good joke: to print its own EXECUTABLE module. But the most funny thing: argv[0] IS NOT an executable file path. It's a name of a program (if it's accessible). For example, VC++ release mode executable module started from (for example) d:\myproject\prog.exe has "prog" as argv[0] argument. Of course, you can't "open the file pointed at by argv[0] " in such a case ;)...

Comments
;)
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.