C++ interpreter / console / snippet compiler

时间秒杀一切 提交于 2019-11-28 10:17:34

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

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

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

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/

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

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.

Kieveli

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!