How to display C program errors on asp.net webpage using C #

I am creating an application for online compilers. I have successfully created with C # .net and VB.net. But when I try to use C and C ++, I don’t know how to display errors on asp.net webpage.

Below is just an error, but not the error address in the code

Process proc = new Process(); proc.StartInfo.FileName = Session[batchPath].ToString(); proc.StartInfo.RedirectStandardError = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.UseShellExecute = false; proc.Start(); 

Is it right, or should I make any changes? Thanks in advance.

+6
source share
2 answers

You get the results of your process using StandardOutput as

 string cResults = proc.StandardOutput.ReadToEnd(); // and then wait to exit. proc.WaitForExit(); 
+1
source

You must:

  • run compiler
  • redirect error output to text file
  • parse text file to find error text, row and column no
  • convert it to your own formatted error messages
  • convert this to something you can display in HTML.

The only tricky part is parsing the error file, but you are not the first. All do this, including all IDEs. Perhaps you can get the code from Eclipse or Netbeans or anywhere.

0
source

All Articles