Please, any one help me to write a c++ program which display its source code???

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.

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.

commented: :) +10

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 ;)...

commented: ;) +10
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.