PDA

View Full Version : a C .exe doesn't read writeToStdin



Shlainn
20th September 2006, 08:34
Please help:

At first I thought QProcess is wrong now by putting in the wroteToStdin signal I determined my .exe written in C doesn't read the stdin.

This is the code:

fgets(serialnmr,sizeof(serialnmr),stdin);

serialnmr is char * and scanf nor gets works :(

wysota
20th September 2006, 09:23
Remember that you need a newline when reading using scanf() or gets().

Shlainn
20th September 2006, 09:53
just to make sure I understand:

for using scanf() and gets() the writeToStdin must be:
proc->writeToStdin("tester\n");

because my code in my QT side is:

proc->writeToStdin("tester\n"); but I use it with:

fgets(serialnmr,sizeof(serialnmr),stdin);

and another thing I see is that nothing is displayed using readFromStdout until the program (my.exe) has exited.

I'm really in a bind please help!

wysota
20th September 2006, 10:51
but I use it with:

fgets(serialnmr,sizeof(serialnmr),stdin);
It doesn't matter. You still need the newline to flush the stdin buffer of your application.

[quote]and another thing I see is that nothing is displayed using readFromStdout until the program (my.exe) has exited.
Maybe you are missing newlines here, too... In the output buffer this time. You can use fflush() instead of the newline to force the flush too.