Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » capturing stdout/err/in of subprocess
Re: capturing stdout/err/in of subprocess [message #1716 is a reply to message #1705] |
Wed, 15 March 2006 00:09 |
gprentice
Messages: 260 Registered: November 2005 Location: New Zealand
|
Experienced Member |
|
|
Quote: | void main() { getchar(); }
Start that. The program will stop, allowing you to enter the line of input characters. Now this "enter the line of characters" is that "echoing" I am speaking about. And, AFAIK, this is not done by program, but terminal (in any case, it is terminal responsibility that if you press backspace, last character is removed from the input line).
|
Wow, I never noticed that. (I don't write console programs much.)
I tried the following program (with Borland compiler on Win XP). If I run it, the first key that gets pressed doesn't get echoed but its numeric value does get printed, then I can press a bunch of keys that do get echoed (and backspace works just as you say) and when I finally press return, the program exits.
getch() is Borland extension (and kbhit) - I think VC has similar ones. I wonder why the first keypress doesn't get echoed. If I change getch() to getchar(), the first character and following characters (until I press return) do get echoed, after which the numeric value gets printed. Maybe getchar() hooks up to a blocking OS function that runs in "line buffer" mode and getch() doesn't run in line mode.
Graeme
#include <stdio.h>
#include <conio.h>
int main()
{
while (1)
{
if (kbhit())
{
printf(" yes");
int k = getch();
printf( "%d", k);
break;
}
}
getchar();
}
|
|
|
|
|
capturing stdout/err/in of subprocess
By: wilho on Mon, 13 March 2006 14:21
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Mon, 13 March 2006 14:50
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Tue, 14 March 2006 09:22
|
|
|
Re: capturing stdout/err/in of subprocess
By: wilho on Tue, 14 March 2006 08:53
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Tue, 14 March 2006 10:54
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: lundman on Tue, 14 March 2006 12:00
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Tue, 14 March 2006 12:04
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Wed, 15 March 2006 09:59
|
|
|
Re: capturing stdout/err/in of subprocess
By: mr_ped on Fri, 17 March 2006 10:52
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Fri, 17 March 2006 12:08
|
|
|
Re: capturing stdout/err/in of subprocess
By: fudadmin on Fri, 17 March 2006 12:11
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Fri, 17 March 2006 12:23
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Fri, 17 March 2006 23:25
|
|
|
Re: capturing stdout/err/in of subprocess
|
|
|
Re: capturing stdout/err/in of subprocess
By: lundman on Sat, 18 March 2006 01:01
|
|
|
Re: capturing stdout/err/in of subprocess
By: mirek on Sat, 18 March 2006 08:47
|
|
|
Re: capturing stdout/err/in of subprocess
By: wilho on Sat, 18 March 2006 14:33
|
|
|
Re: capturing stdout/err/in of subprocess
By: lundman on Sat, 18 March 2006 15:05
|
Goto Forum:
Current Time: Sat May 04 07:41:11 CEST 2024
Total time taken to generate the page: 0.02205 seconds
|