Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to display the program code as output using C or C++

How to display the program code as output using C or C++

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++helptutorial
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Karan_TN
    wrote on last edited by
    #1

    hai, i would like to display the coding. Means, while i m running my C/C++ program the output should be of the program coding which i m execting..... how can i do it? Help me! Thanks for understanding!!!

    enhzflepE P 2 Replies Last reply
    0
    • K Karan_TN

      hai, i would like to display the coding. Means, while i m running my C/C++ program the output should be of the program coding which i m execting..... how can i do it? Help me! Thanks for understanding!!!

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      You need to (A) debug a debugger or (B) dissasemble/decompile a dissasembler/decompiler Then, the program running would be doing nothing other than producing output that contained the program's source-code I don't understand your question, as it stands. The effort would be pointless - an act of 'because I can'

      K 1 Reply Last reply
      0
      • enhzflepE enhzflep

        You need to (A) debug a debugger or (B) dissasemble/decompile a dissasembler/decompiler Then, the program running would be doing nothing other than producing output that contained the program's source-code I don't understand your question, as it stands. The effort would be pointless - an act of 'because I can'

        K Offline
        K Offline
        Karan_TN
        wrote on last edited by
        #3

        Thanks for immediate reeply for example... my program coding is..

        #include
        #include
        void main()
        {
        float n1,n2,ans;
        }

        And the program output should be.... #include #include void main() { float n1,n2,ans; } how to achieve it? thanks in advance

        enhzflepE 1 Reply Last reply
        0
        • K Karan_TN

          Thanks for immediate reeply for example... my program coding is..

          #include
          #include
          void main()
          {
          float n1,n2,ans;
          }

          And the program output should be.... #include #include void main() { float n1,n2,ans; } how to achieve it? thanks in advance

          enhzflepE Offline
          enhzflepE Offline
          enhzflep
          wrote on last edited by
          #4

          Ahhhh.... I was afraid you were going to say that or words to that effect. What you're looking for is a decompiler or a dissasembler. The difference is in the 'high-level'ness of their output. A dissasembler will turn a piece of executable code into an assembly listing. A decompiler on the other hand, will produce C (or most any other high level language within reason) code from an executable. While it is true that a fairly large number of people have written dissasemblers, the same can't be said for decompilers. It is a notoriously difficult & complex subject. HexRays has a product that will turn an exe file into C source code - it is the $2000 plugin for IDA Pro interactive dissasembler. You can find more info on HexRays here (they have a free version of IDAPro) http://www.hex-rays.com/products.shtml[^] Also, here are some links to decompilers/dissasemblers that people have coded themselves: http://www.woodmann.com/collaborative/tools/index.php/Category:Decompilers[^] http://www.woodmann.com/collaborative/tools/index.php/Category:Disassemblers[^] 'luck.

          K 1 Reply Last reply
          0
          • enhzflepE enhzflep

            Ahhhh.... I was afraid you were going to say that or words to that effect. What you're looking for is a decompiler or a dissasembler. The difference is in the 'high-level'ness of their output. A dissasembler will turn a piece of executable code into an assembly listing. A decompiler on the other hand, will produce C (or most any other high level language within reason) code from an executable. While it is true that a fairly large number of people have written dissasemblers, the same can't be said for decompilers. It is a notoriously difficult & complex subject. HexRays has a product that will turn an exe file into C source code - it is the $2000 plugin for IDA Pro interactive dissasembler. You can find more info on HexRays here (they have a free version of IDAPro) http://www.hex-rays.com/products.shtml[^] Also, here are some links to decompilers/dissasemblers that people have coded themselves: http://www.woodmann.com/collaborative/tools/index.php/Category:Decompilers[^] http://www.woodmann.com/collaborative/tools/index.php/Category:Disassemblers[^] 'luck.

            K Offline
            K Offline
            Karan_TN
            wrote on last edited by
            #5

            thanks for your reply. whether this can be achieve in .net easily? or someother language?

            enhzflepE 1 Reply Last reply
            0
            • K Karan_TN

              thanks for your reply. whether this can be achieve in .net easily? or someother language?

              enhzflepE Offline
              enhzflepE Offline
              enhzflep
              wrote on last edited by
              #6

              Pleasure. In every case I can immediately think of, these tools are compiled to native code. This of course implies the use of C/C++, asm & pascal though I've no idea if anything .NET would be suitable or not - I would assume it to be possible, albeit slow in execution on account of the code being interpreted at runtime. Lutz Roeder's .NET Reflector will give you the source code of a .NET executable. The Deblector & Reflexil plugins are invaluable - HOWEVER these are all only available as binaries, so of very little to no interest to somebody trying to create a tool that achieves the same task.

              K 1 Reply Last reply
              0
              • enhzflepE enhzflep

                Pleasure. In every case I can immediately think of, these tools are compiled to native code. This of course implies the use of C/C++, asm & pascal though I've no idea if anything .NET would be suitable or not - I would assume it to be possible, albeit slow in execution on account of the code being interpreted at runtime. Lutz Roeder's .NET Reflector will give you the source code of a .NET executable. The Deblector & Reflexil plugins are invaluable - HOWEVER these are all only available as binaries, so of very little to no interest to somebody trying to create a tool that achieves the same task.

                K Offline
                K Offline
                Karan_TN
                wrote on last edited by
                #7

                ah... this much complicated is there??? since this question was raised by my professor. He ask to find the answer and the coding for this.

                1 Reply Last reply
                0
                • K Karan_TN

                  hai, i would like to display the coding. Means, while i m running my C/C++ program the output should be of the program coding which i m execting..... how can i do it? Help me! Thanks for understanding!!!

                  P Offline
                  P Offline
                  PravinSingh
                  wrote on last edited by
                  #8

                  The program that reproduces its own source as output is called quine (After American logician Willard Van Orman Quine). There are many ways to do it, but rather than I give you a complete working example, I'd appreciate if you google for quine and go through the results. :)


                  It's better to know some of the questions than all of the answers.
                  Pravin.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups