Unexpected number of closed streams

In this piece of (simplified) code below I get as a unexpected result : "4 streams flushed" after opening 1 file and flushing all open streams with _flushall afterwards.
I cannot figure out which 3 other streams were opened.

Thanx in advance for any suggestions.

#include "stdafx.h"
#include

FILE *stream1;
int main(int argc, char* argv[])
{
stream1 = fopen( "data1" ,"w+");
//flush or close all streams before calling system
int numflushed;
numflushed = _flushall();
printf( "%d streams flushed
", numflushed ); // OUTPUT: 4 ???
// use copy to copy the data1.cpp file
system("copy data1,kopie");
//use system to type the copy file
system( "type kopie" );
// use remove to remove the copy2
remove ("kopie2");
// use rename to rename the copy file
rename("kopie", "kopie2");
return 0;
}

Comments

  • : In this piece of (simplified) code below I get as a unexpected result : "4 streams flushed" after opening 1 file and flushing all open streams with _flushall afterwards.
    : I cannot figure out which 3 other streams were opened.

    stdin, stdout and stderr?

    :
    : Thanx in advance for any suggestions.
    :
    : #include "stdafx.h"
    : #include
    :
    : FILE *stream1;
    : int main(int argc, char* argv[])
    : {
    : stream1 = fopen( "data1" ,"w+");
    : //flush or close all streams before calling system
    : int numflushed;
    : numflushed = _flushall();
    : printf( "%d streams flushed
    ", numflushed ); // OUTPUT: 4 ???
    : // use copy to copy the data1.cpp file
    : system("copy data1,kopie");
    : //use system to type the copy file
    : system( "type kopie" );
    : // use remove to remove the copy2
    : remove ("kopie2");
    : // use rename to rename the copy file
    : rename("kopie", "kopie2");
    : return 0;
    : }
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion