在文本框中编译代码 [英] Compiling Code in a Textbox

查看:96
本文介绍了在文本框中编译代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用C#构建一个程序,该程序可以在一个文本框中编译用C语言编写的代码,并在另一个文本框中显示结果.

如果您能帮助我,我将非常感谢.

-------------------------------------------------- -

我所需要的只是一段代码,该代码将编译一个简单的C代码(stdio和数学库,没有指针或内存管理..),该代码编写在textBox中,并在另一个文本框中显示结果.我不在乎你要怎么做.

-------------------------------------------------- -

克里斯汀·格劳斯(Christian Graus),如果您不知道解决方案,请不要对我的问题添加答案.
首先,这不是家庭作业.这是我选择添加到我的项目中的一部分.是的,这会给我额外的荣誉,但不会让我失望.
其次,如果你们都不想要帮助,为什么你们要拥有这个网站??:thumbsdown:

-------------------------------------------------- -

我是一名硕士生,这是我的最后一个项目.我的项目完全是关于其他事情的,但是要使其完整,我想在其中添加这一功能.

我的教授告诉我,将编译器添加到我的项目中会很困难,并建议仅显示代码.

此外,我不是小偷,也无法从任何人那里窃取任何东西.如果有人帮助我,我会在我的项目中包括网站和人员名称/昵称.

相信我,说话很容易,但是当您开始编写代码时,您会像我一样被困住.我尝试了互联网上的所有内容,但无济于事.所有非C语言编译C#或VB代码的解决方案.

如果这是我的整个项目,您是否认为我要等到四天之后才能提交我的项目?如果您的目标语言是C#,您将如何做:
动态代码生成和代码编译 [

我尝试了互联网上的所有内容,但没有任何作用



您是说无法下载
免费的C编译器,将文本保存到临时文件中,然后传递该文件路径作为编译器的命令行参数,并将结果加载到文本框中?对我来说听起来很简单.另外,有时答案不是在互联网上" ...有时您必须自己创建答案.


将第一个文本框中的文本存储到一个临时文件中,运行使用该文件作为参数之一的C ++编译器,读取编译器输出的文件并将结果存储在第二个文本框中.

不要对您的电子邮件提出疑问...当自动程序将其自动接收时,它会让您垃圾邮件.


Hi,

I''m using C# to build a program that compiles code writen in C in a textbox, and shows the results in another textbox.

I would be very thankful if you help me.

----------------------------------------------------

All what I need is a piece of code which will compile a simple C code (stdio and math librarys, no pointers or memory management..) that written in the textBox and display the results in another. I don''t care how you are going to do it.

----------------------------------------------------

Christian Graus, if you don''t know the solution, don''t add an answer to my question.
first of all, this is not a homework. this is a part of my choice to add to my project. yes it would give me an extra credit, but it won''t fail me.
second, why do you guys have this web site if non of you want to help??:thumbsdown:

----------------------------------------------------

I''m a Master student and this is my final project. my project is totally about something else, but to make it complete I want to add this piece of feature in it.

my professor told me it''s going to be difficult to add the compiler to my project and suggested to just show the code.

besides, I''m not a thief, and I can''t steal anything from anybody. if someone helped me I''ll include the site and the person name/nickname in my project.

and believe me, talking is easy, but when you start doing the code you''ll be stuck like me. I tried everything in the internet and nothing is working. all the solutions to compile a C# or VB codes not for C.

if this is my whole project, do you think I would wait until it''s four days before turning in my project??!!

解决方案

This is an example how you would do it if your target language was C#:
Dynamic Code Generation and Code Compilation[^]

However, if you want to do anything useful with this - and especially using C++ - it would get quite complex quite soon: you would need to start handling refereences, memory management, application domains, consider the security of running arbitrary code and a lot of other things.

Based on your level of questions, it would be too difficult for you to do. You really need a more experienced programmer who also knows C++ to complete this programming task.


omar44 wrote:

I tried everything in the internet and nothing is working



Are you saying you can''t download a free C compiler, save the text to a temp file, then pass that file path as a command line argument to the compiler and the load the result into the textbox? Sounds pretty simple to me. Also, sometimes the answer isn''t "in the internet"... sometimes you have to create it yourself.


Store the text in the first textbox to a temporary file, run a C++ compiler with that file as one of the parameters, read in the file that the compiler outputs and store the result in the second textbox.

Don''t put your email in questions... it will get you spammed when bots automatically pick it up.


这篇关于在文本框中编译代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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