Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
1.29/5 (7 votes)
See more:
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??!!
Posted
Updated 24-Feb-10 16:40pm
v10

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.
 
Share this answer
 
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.
 
Share this answer
 
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.
 
Share this answer
 
omar44 wrote:
Christian Graus, if you don't know the solution, don't add an answer to my question.


I know the answer, in fact, it's already been given to you, so I did not reiterate it. It's painfully obvious how to do this, I don't see how you've failed to impliment it, or at least understand the answer.

omar44 wrote:
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.


So, it's just an extra credit you want us to help you cheat on, and that makes it OK ? It doesn't matter. We told you how to do it, if you don't understand the answer, then that's not really our fault, and an indication you don't deserve that extra credit.

omar44 wrote:
second, why do you guys have this web site if non of you want to help??


I spend hours every day wading through and responding to people who want us to do their course work, or who have got outsourced jobs because they do them for next to nothing, when they barely know how to type and expect the western developers whose jobs they are stealing, to do the work for them. I do that because it gives me great pleasure to find questions from real programmers, people who know what they are doing, know how to use google, invest in books to learn, but have got themselves stuck on a specific point after reading the documentation and trying to do their own work. People like you benefit from the pleasure I get from helping the few real programmers still working this industry.

You don't want help, you want us to do the work, so you can pass it off as your own. Or did you intend to tell your teachers that parts of your code were done by random strangers on the web for you ?
 
Share this answer
 
Please don't post 'answers' to yourself, edit your post. There is no C# code for you to write, especially. You will save the contents of the textbox into a file and use Process.Start to run the command line compiler to compile the C++ code. Why would you need to do this anyhow ?

"I have 4 days to turn in my project" - well, then you're going to fail. Offering to pay someone to do your school work for you means you deserve to fail.
 
Share this answer
 
v2
omar44 wrote:
if this is my whole project, do you think I would wait until it's four days before turning in my project??!!


Frankly, if you did, you'd not be the first.


omar44 wrote:
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.


Compiling C code is a totally different proposition to .NET, obviously. I still don't think it would be all that complex. I would certainly be more sympathetic if you posted the code you had written and asked for help from there.
 
Share this answer
 
hi frend, this will help you: http://blogs.msdn.com/deeptanshuv/archive/2005/06/26/432870.aspx

& ignore GROSS
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900