[mpich-discuss] scanf with MPICH2 for Win7

Rajeev Thakur thakur at mcs.anl.gov
Thu Mar 22 21:05:52 CDT 2012


Try adding an fflush(stdout); after the printf.

On Mar 22, 2012, at 4:25 PM, Alejandro Allievi wrote:

> Hi,
> 
> I'm running a Get-input(...) function that takes input from stdin with
> the following code  snippet
> ......
> 
>   if (my_rank == 0) {
>      printf("Enter a, b, and n\n");
>      scanf("%lf %lf %d", a_p, b_p, n_p);
> ...
> }
> 
> It compiles and runs giving the right result, no problem. HOWEVER, the
> scanf seems to execute before the printf. In other words, when I run
> the program I need to enter a, b and n and then "Enter a, b, and n"
> appears on my screen, and the program runs correctly to completion. It
> does not happen in UNIX, only happens in MPICH2 for Win7 64bit.
> 
> Has anybody encountered this problem or has any hints on its cause???
> 
> Thank you.
> 
> Alex
> _______________________________________________
> mpich-discuss mailing list     mpich-discuss at mcs.anl.gov
> To manage subscription options or unsubscribe:
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss



More information about the mpich-discuss mailing list