printf("A\n");  
  cout<<"B\n";  
  printf("C\n");  
the   ouput      is :  
  A  
  C  
  B   
not:  
  A  
  B  
  C 
why? 

answer:   
   
  1.   you   shouldn't   mix   "printf()"   and   "cout"   in   the   same   program   because   C   stdio   and   C++   iostreams   are   completely   independent   and   they   may   have   different   buffering   scheme   and   they   don't   share   the   same   buffer,   so   the   ouput   may   come   out   in   an   order   that   you   are   not   expecting,   that   is   probably   what   happened   in   your   case  
   
  2.   try  
   
  cout   <<   "B"   <<   endl;  
   
  or   call    
   
  ios::sync_with_stdio();

相关文章:

  • 2022-02-16
  • 2022-03-07
  • 2021-08-28
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2021-10-02
猜你喜欢
  • 2021-11-01
  • 2021-10-11
  • 2022-12-23
  • 2021-11-29
  • 2021-11-25
  • 2021-10-25
相关资源
相似解决方案