From: Keith M. <kei...@to...> - 2005-10-20 09:23:33
|
Ulrich Lauther wrote: > VC++ provides the functions _getch() and _getche() for reading > one character from stdin without buffering, i.e., one gets the > character without having to press the enter key. > > This works fine in a DOS-window, but not from a MSYS (rxvt?) > window. > > I assume the problem is related to the "feature" that > fflush(stdout) is needed to show output, ... I believe your assumption to be correct; this issue has been discussed to death, on this very list, in the past. Earnie has tried hard to find a solution, without success. > ... however, fflush(stdin) doesn't help. Naturally. All fflush() on *any* input stream achieves is to discard any pending data from the input buffer. > Is there a way around this problem? Probably not the one that you want to hear, but the one that I myself have adopted -- run MSYS in a native Windoze console; (either start it with the --norxvt switch, or rename/delete rxvt.exe in/from your msys/1.0/bin directory, before you start the session). You will lose the job control features, and you must use Ctrl-Z as an EOF signal, rather than Ctrl-D. HTH. Regards, Keith. |
From: Keith M. <kei...@to...> - 2005-10-20 10:43:57
|
Ulrich Lauther wrote, quoting me: >> I believe your assumption to be correct; this issue has been >> discussed to death, on this very list, in the past. Earnie has >> tried hard to find a solution, without success. > > Thanks a lot for your explanation. I am new to this list and > serached the archives for _getch without finding the relevant > discussion. Probably the _getch() issue wasn't mentioned specifically; the discussion centred more on the output aspects of the problem. The problem lies in the `pty' emulation layer that MSYS rxvt places between the OS I/O subsystem and the tangible user interface; that seems to buffer I/O, regardless of what the user's application is trying to achieve, and so far, no way around this can be identified. Running in a native console omits the emulation layer, and so avoids the problem, but you pay for it in terms of features and performance; (strangely, it may seem, in spite of the pty emulation, MSYS rxvt actually performs screen writes *faster* than the native console). Search terms such as "msys rxvt pty" would have been more likely to turn up the relevant references. Regards, Keith. |
From: haibin z. <dr...@ya...> - 2005-10-21 03:23:53
|
Hi all: I want to input password in console, I found getche() can finish this function,when you input a char, it don't echo in console, but when I test it in mingw , it will echo char in console, is it correctly? How can implement this function in mingw? thanks this is result: $ ./a.exe Input a character:e <- echo in console You input a 'e' the following is source code #include <stdio.h> #include <conio.h> int main(void) { char ch; printf("Input a character:"); ch = getche(); printf("\nYou input a '%c'\n", ch); return 0; } ___________________________________________________________ 雅虎免费G邮箱-中国第一绝无垃圾邮件骚扰超大邮箱 http://cn.mail.yahoo.com |
From: Greg C. <chi...@co...> - 2005-10-21 03:51:11
|
On 2005-10-21 3:14 UTC, haibin zhang wrote: > > I want to input password in console, I found getche() > can finish this function,when you input a char, it > don't echo in console, but when I test it in mingw , > it will echo char in console, is it correctly? How can > implement this function in mingw? Both nonstandard functions getch() and getche() get a character from the keyboard. The difference is that getche() echoes the character, and getch() does not. For a password, you probably want getch(), not getche(). |
From: haibin z. <dr...@ya...> - 2005-10-21 04:36:10
|
--- Greg Chicares <chi...@co...>写道: > On 2005-10-21 3:14 UTC, haibin zhang wrote: > > > > I want to input password in console, I found > getche() > > can finish this function,when you input a char, it > > don't echo in console, but when I test it in > mingw , > > it will echo char in console, is it correctly? How > can > > implement this function in mingw? > > Both nonstandard functions getch() and getche() get > a > character from the keyboard. The difference is that > getche() echoes the character, and getch() does not. > For a password, you probably want getch(), not > getche(). thanks, sorry , I am wrong, it work correctly > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, > downloads, discussions, > and more. > http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Mingw-msys mailing list > Min...@li... > https://lists.sourceforge.net/lists/listinfo/mingw-msys > ___________________________________________________________ 雅虎免费G邮箱-No.1的防毒防垃圾超大邮箱 http://cn.mail.yahoo.com |
From: Ulrich L. <ulr...@si...> - 2005-10-20 10:09:50
|
> > I believe your assumption to be correct; this issue has been > discussed to death, on this very list, in the past. Earnie has > tried hard to find a solution, without success. > Thanks a lot for your explanation. I am new to this list and serached the archives for _getch without finding the relevant discussion. Sorry, -ulrich lauther ---------------------------------------------------------------------------- Ulrich Lauther ph: +49 89 636 48834 fx: ... 636 42284 Siemens CT SE 6 Internet: Ulr...@si... |