Why is Process.StandardInput.WriteLine not supplying input to my process?

前端 未结 2 1961
不思量自难忘°
不思量自难忘° 2020-12-21 02:57

this is my first question here so I\'ll be as detailed as I can. I am currently working on a C# program (We\'ll call it TestProgram) that tests a different program written i

2条回答
  •  攒了一身酷
    2020-12-21 03:24

    I think the problem is in your C program, not in your C# program. When you produce your output, you do not put \n at the end. Hence StandardOutput.ReadLine() will wait forever, because there is no end-of-line marker in the stream.

    Since the output of your C program is used to synchronize the steps of your co-operating programs, it is also a very good idea to flush it to the output before waiting for the next portion of input:

    printf("%s\n", result);
    fflush(stdout);
    

提交回复
热议问题