c++ - Eclipse (or maybe windows is to blame?) won't print unless I fflush(stdout) -
i installed eclipse , mingw on sister's computer running windows 7.
 while testing see if set properly, noticed won't print anything:  
#include<stdio.h>  int main() {     int x;      printf("hello world!\n");     printf("enter number... \n");     scanf("%d", &x);     printf("you entered %d", x);     return 0; } instead, waits input, , print whole thing @ once.
 here's how looks:  
345 hello world! enter number...  entered 345 it after added call fflush(stdout) after printf("enter number... \n"); eclipse printed in right order, meaning, code:  
#include<stdio.h>  int main() {     int x;      printf("hello world!\n");     printf("enter number... \n");     fflush(stdout);     scanf("%d", &x);     printf("you entered %d", x);     return 0; } works expected.
 worth mentioning opened separate c++ project , tried same thing:  
#include<iostream>  int main() {     int x;     std::cout<<"hello!\n";     std::cout<<"enter number\n";     std::cin>>x;     std::cout<<"you entered "<<x; } this worked fine, , prints without need of flushing anything...
 why eclipse delay output in c projects? 
do not give :) hope similar question helps you:
c/c++ printf() before scanf() issue
also, guess not ide specific ! cheers
Comments
Post a Comment