C++ interpreter / console / snippet compiler

后端 未结 6 595
醉酒成梦
醉酒成梦 2020-12-10 07:24

I am looking for a program where I can enter a C++ code snippet in one window, press a button, and get output in another window. Compilation should somehow be hidden behind

相关标签:
6条回答
  • Do something like this ? test a C# snippet code by just copying it to the clipboard and then type csc.exe: http://reboltutorial.com/blog/redirect-shell-to-rebol-console/

    0 讨论(0)
  • 2020-12-10 07:35

    Just configure your code editor to compile and run your code snippets.

    Most code editors have the capability of 'sending' the current buffer/file to an external tool. I configure one editor key binding to compile the current buffer, and another key binding to execute whatever was last compiled (actually to run whatever has the same base filename as the current buffer with an '.exe' extension). My experience is with Windows, but the same or similar can be done on Unix/Linux.

    Then it becomes one keystroke to compile and another to run what I jut compiled. This could also easily be just a single keystroke to compile & run, but I have several key bindings set to compile using various different compilers. That way I can easily test snippets using the latest MSVC, MSVC 6, MinGW GCC, Comeau and Digital Mars compilers to check for differences.

    0 讨论(0)
  • Cling (interactive C++ interpreter, built on the top of LLVM and Clang libraries): https://root.cern.ch/drupal/content/cling

    0 讨论(0)
  • 2020-12-10 07:53

    I would do it like this:

    • Capture the 'snippit' as text
    • Create a.cpp with the following:
    int main() {
      snippitCode();
      return 0;
    }
    
    void snippitCode() {
      // INSERT SNIPPIT HERE
    }
    
    • Use 'exec' to launch a compiler and pipe the output to an output file.
    • Use 'exec' to run the application and pipe the output to an output file.

    In the 'output' window, you can run 'tail -f' on the output file to continuously update when new output arrives.

    0 讨论(0)
  • 2020-12-10 07:55

    http://codepad.org/ works nicely for this purpose. By default, it will run what you paste when you hit submit and display the result (or any errors you might have).

    0 讨论(0)
  • 2020-12-10 07:55

    Dinkumware has a page for this AND you can choose the compiler

    http://dinkumware.com/exam/default.aspx

    0 讨论(0)
提交回复
热议问题