B
bruce varley
Hello,
I suspect a platform bug, but first I'd like to check whether the C++
standard library has changed the handling of streams in a way that creates
the
behaviour I'm observing. Hence this posting.
The following code fails when it's compiled with standard library, but
works without, refer to the commented sections. When failing, only the
first file open succeeds, subsequent ones generate an error. Is this
explainable 'within the rules?'
If anyone would like more information on specific platform details, email
me.
(e-mail address removed)
remove ecks and kyoo to email.
// works with this active
// *******************************************
#include <iostream.h>
#include <fstream.h>
// *******************************************
// Fails with this active
// *******************************************
#include <iostream>
#include <fstream>
using namespace std ;
// *******************************************
int main()
{
ifstream ifs ;
int i ;
char c ;
for (i = 0; i < 5; i++)
{
ifs .open ("TEST.TXT") ;
if (!ifs)
{
cout << "\nERROR" ;
return 1 ;
}
while (ifs) ifs.get (c) ;
ifs.close() ; // Strictly unnecessary, since stream has terminated.
// Removing makes no difference.
}
return 0 ;
}
I suspect a platform bug, but first I'd like to check whether the C++
standard library has changed the handling of streams in a way that creates
the
behaviour I'm observing. Hence this posting.
The following code fails when it's compiled with standard library, but
works without, refer to the commented sections. When failing, only the
first file open succeeds, subsequent ones generate an error. Is this
explainable 'within the rules?'
If anyone would like more information on specific platform details, email
me.
(e-mail address removed)
remove ecks and kyoo to email.
// works with this active
// *******************************************
#include <iostream.h>
#include <fstream.h>
// *******************************************
// Fails with this active
// *******************************************
#include <iostream>
#include <fstream>
using namespace std ;
// *******************************************
int main()
{
ifstream ifs ;
int i ;
char c ;
for (i = 0; i < 5; i++)
{
ifs .open ("TEST.TXT") ;
if (!ifs)
{
cout << "\nERROR" ;
return 1 ;
}
while (ifs) ifs.get (c) ;
ifs.close() ; // Strictly unnecessary, since stream has terminated.
// Removing makes no difference.
}
return 0 ;
}