www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000132

When Created: 01/27/1997 11:13:25
Against DJGPP version: 2.01
By whom: silverio@cu.lu
Abstract: can't use cin once en eof occurred (BC5 behaves differently)
Can anybody explain why the following code works with BC5.0 and does not
work with DJGPP gcc version 2.7.2.1 ? The problem is that if the user
enters an EOF (CTRL Z in DOS) to stop the loop, the user is not prompted
to enter the double d ! Is this a bug or not. I can't find an explanation !

#include <iostream.h>
int main() {
  int i;
  while(cin >> i) cout << i << endl;  // CTRL Z to stop the loop
  cin.clear();                        // reset the flags    
  double d;
  cin >> d;                           // with DJGPP gcc, the user cannot
enter a value 
  cout << d << endl;
}

Many thanks

Nino Silverio

Note added: 04/13/1999 07:00:20
By whom: eliz@is.elta.co.il
This is a DOS misfeature: the EOF condition for the console device is
not cleared until something is written to the console.

Workaround added: 04/13/1999 07:00:10
By whom: eliz@is.elta.co.il
Output an empty string to the console device before calling cin.

Closed on 04/13/1999 07:00:53: DOS misfeature, not a DJGPP bug.
By whom: eliz@is.elta.co.il



  webmaster     delorie software   privacy  
  Copyright © 2010   by DJ Delorie     Updated Jul 2010