Click here to Skip to main content
16,018,394 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am trying a make C IDE (Integrated Development Environment ) using C#.Net in Windows 7. So I need Compile and executed C program and Display output and Error Messages in textbox or Label

Displaying output and Error Messages can easily done
C#
pp.RedirectStandardOutput = true;
            pp.UseShellExecute = false;
            pp.CreateNoWindow = true;
            pp.RedirectStandardError = true;
            Process p = new Process();
            p.StartInfo = pp;
            p.Start();

            StreamReader sr = new StreamReader(p.StandardOutput.BaseStream, p.StandardOutput.CurrentEncoding);
            string line = "";
            string output = "";

            while ((line = sr.ReadLine()) != null)
            {
                output += line;
            }
            p.WaitForExit();
            p.WaitForExit();

            textBox1.Text = output;



but how can i execute a program that takes inputs from user programs like this
C++
void main()
{
int a;
printf("/nEnter a Number");
scanf("%d",&a);
printf("Number is  %d",a);
}



and display output or error Messages in a textbox or label?

i tried StandradInput
C#
p.StandardInput.WriteLine("7");
but its doesn't work for me.
Posted
Updated 9-Jan-14 4:08am
v2
Comments
PIEBALDconsult 9-Jan-14 10:35am    
Wouldn't you need to redirect the input as well?
I do things about the way you have it, but I allow the user to respond to the prompts rather than trying to automate it.
manuthebos 9-Jan-14 11:54am    
Compiler and IDE are in different systems that are connected by network. so the input must enter from at time of execution. that i need redirect the input
manuthebos 9-Jan-14 19:19pm    
In my case user is situated in other system. so he can't directly type input into that prompt.
Richard MacCutchan 9-Jan-14 11:01am    
You could try the VS approach and run the program in a command window.
manuthebos 9-Jan-14 11:54am    
VS Approach means. ?

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