home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11805 < prev    next >
Encoding:
Text File  |  1992-07-30  |  1.6 KB  |  74 lines

  1. Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!yale.edu!yale!gumby!destroyer!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!epx.cis.umn.edu!wright
  2. From: wright@epx.cis.umn.edu (Mark Wright)
  3. Newsgroups: comp.lang.c++
  4. Subject: Bizarre Borland stream bug
  5. Message-ID: <1992Jul30.185327.662@news2.cis.umn.edu>
  6. Date: 30 Jul 92 18:53:27 GMT
  7. Sender: news@news2.cis.umn.edu (Usenet News Administration)
  8. Organization: University of Minnesota
  9. Lines: 62
  10. Nntp-Posting-Host: epx.cis.umn.edu
  11.  
  12. OK, now this is REALLY silly. I'm compiling the following program
  13. under Borland C++ v3.1.  All it does is read in a file with the format
  14. given below.  It looks like borland's stream class DOESN'T LIKE THE
  15. NUMBER NINE!!!  Am I doing something weird, is this the compiler, or
  16. should I call in an exorcist...
  17.  
  18.  
  19. #include<iostream.h>
  20. #include<fstream.h>
  21.  
  22. struct PointRecord {
  23.   int pointno;
  24.   double x;
  25.   double y;
  26. };
  27.  
  28.  
  29. void main( int argc, char *argv[] )
  30. {
  31.   PointRecord point;
  32.   ifstream inFile( argv[1], ios::in );
  33.  
  34.   for (;;) {
  35.     if (!(inFile >> point.pointno))
  36.       break;
  37.     if (!(inFile >> point.x))
  38.       break;
  39.     if (!(inFile >> point.y))
  40.       break;
  41.  
  42.  
  43.     cout << point.pointno << ": "
  44.          << point.x       << ", "
  45.          << point.y       << endl;
  46.   }
  47. }
  48.  
  49.  
  50. /*
  51. FILE 1:
  52. 0001    111111.1111     111111.1111
  53. 0009    222222.2222     222222.2222
  54.  
  55. PROGRAM OUTPUT:
  56. 1: 111111.1111, 111111.1111
  57. 0: 9, 222222.2222
  58.  
  59.  
  60. FILE 2:
  61. 0009    222222.2222     222222.2222
  62. 0001    111111.1111     111111.1111
  63.  
  64. PROGRAM OUTPUT:
  65. 0: 9, 222222.2222
  66. 25614: 0.2222, 1
  67. -19961: 0.1111, 111111.1111
  68. */
  69.  
  70.  
  71.  
  72. Mark Wright
  73. wright@epx.cis.umn.edu
  74.