I’ve got a program that deals with both Ascii and binary PGM images. I open the file open mode using:
ifstream istr(argv[i]);
After reading in the header of the PGM file, that determines if I’m dealing with binary data or ASCII. Is there a way then to change the istr to the binary mode?
1> You would have first clear the stream by calling
Clearmethod to reset the mode of the stream(required if your stream has hit anend-of-fileor has encountered anerror)2> You would have to close the stream by calling
closemethod3> Finally you have to call the
openmethod to open the new file with the desired filemode