amarendar-musham / mintty

Automatically exported from code.google.com/p/mintty
GNU General Public License v3.0
0 stars 1 forks source link

The order of input and output are disordered. #407

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
// m.c
#include <stdio.h>
int main(void)
{
    char str[50];
    printf("Press string: ");
    scanf("%s", str);
    printf("Your string is %s.\n", str);
    return 0;
}

$ gcc m.c -o m.exe

What is the expected output? 

>> $ m.exe
>> Press string: abc
>> Your string is abc.

What do you see instead?

>> $ m.exe
>> abc
>> Press string: Your string is abc.

What versions of mintty, Cygwin/MSYS, and Windows are you using?

MinTTY: 1.1.1~1.1.3
GCC: 4.7.2
OS: WinXP
MinGW/MSYS: 2012.04.26~2013.10.04

Please provide any additional information below.

1. cin and cout in C++ is ok.
2. If we use _getch() or system("pause") or getchar() at the end of program, it 
can't return back.

Original issue reported on code.google.com by boy3...@gmail.com on 14 Oct 2013 at 3:17

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have this problem too.
MinTTY: 1.0.3, 1.1.3
GCC: 4.7.2
OS: Windows 7, Windows 8
MinGW/MSYS: mingw-get-inst-20120426
CodePage: UTF-8; CP1251; CP866

"GNU gdb"
in MinTTY:
    sdafsadf
    (gdb) Undefined command: "sdafsadf".  Try "help".
    sadfsdaf
    (gdb) Undefined command: "sadfsdaf".  Try "help".
in CMD:
    (gdb) sadfsadf
    Undefined command: "sadfsadf".  Try "help".
    (gdb) sadfsadf
    Undefined command: "sadfsadf".  Try "help".
    (gdb)

Sorry for my English.

Original comment by Muhamatn...@gmail.com on 22 Oct 2013 at 6:40

GoogleCodeExporter commented 8 years ago
I have solved this problem. I should use "fflush(stdout)".
Such as:

// m.c
#include <stdio.h>
int main(void)
{
    char str[50];
    printf("Press string: ");
    fflush(stdout);
    scanf("%s", str);
    printf("Your string is %s.\n", str);
    return 0;
}

Original comment by boy3...@gmail.com on 7 Nov 2013 at 11:04