从Asp.net应用程序运行C / C ++程序 [英] Run C/C++ program from Asp.net application

查看:80
本文介绍了从Asp.net应用程序运行C / C ++程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我是ASP.NET新手,我在这里遇到挑战:



我必须创建一个网页,该网页应该从textarea中获取C / C ++程序,并且当在网页上点击一个按钮时,应该使用标签在textarea下面生成程序的输出。



我在创建首页(textarea,按钮,标签或其他控件)和阅读后端页面(cs页面)中的textarea内容时没有任何困难。



但是我不知道如何编译和运行从textarea读取的程序并生成可以分配给网页上的标签的输出。



非常感谢任何帮助。



问候,

Raj

Hi,

I am new to ASP.NET and I have a challenge here:

I have to create a webpage which should take C/C++ program from textarea and should produce output of the program below the textarea using label when a button is clicked on the webpage.

I have no difficulty creating the front page(textarea,button,label or other controls) and reading the content of textarea in back end page(cs page).

But I don't have any idea how I can compile and run the program read from textarea and produce the output which can be assigned to a label on webpage.

Any help on this will be much appreciated.

Regards,
Raj

推荐答案

你对运行C / C ++程序的意思是什么?

What do you mean at "Run C/C++ program"?

如果你想启动另一个进程,你可以使用进程类。

If you want to start another process, you can use the Process class.

如果要从托管代码中调用C ++函数,可以看到我的CP文章:将本机公开给托管 - C ++ / CLI与P / Invoke

If you want to call a C++ function from your managed code, you can see my CP article about: Exposing native to managed - C++/CLI vs. P/Invoke.


可能你可以:

  • 将文本保存到(源)文件中。
  • 使用实际的 C / C ++ 编译器编译源文件。
  • 成功编译后,运行可执行文件,将其输出重定向到文本文件,例如 out.txt
  • 在页面中显示 out.txt 内容。
Probably you could:
  • Save your text into a (source) file.
  • compile the source file using an actual C/C++ compiler.
  • Upon successfull compilation, run the executable redirecting its output to a text file, say out.txt
  • Show the out.txt content in your page.


这篇关于从Asp.net应用程序运行C / C ++程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆