fasoulas
March 31st, 2010, 08:26 PM
what is the difference between ?
ofstream out("data.txt" , ios::out | ios::in);
AND
ofstream out("data.txt");
i was trying to do a piece of code to work for hours and when i wrote
ios::out | ios::in as a second parameter to this output file stream my code worked and the stream wrote the data to the file a wanted,whereas before it hasn't happening
Why an output file stream needs ios::in and ios::out to write to a file?
This is a striped down version of my code
ifstream read ;
ofstream writeout ;
read.open("data.txt") ;
somefunction(num , ID , price , size , read );
readF.close() ;
do
{
readF.open("data.txt") ;
writeout.open("out.txt" , ios::out | ios::in);
//this function must write data to a file
someotherfunction(writeout , num , ID);
////////CODE//////////
read.close();
writeout.close();
}while(...);
sorry for my bad english
ofstream out("data.txt" , ios::out | ios::in);
AND
ofstream out("data.txt");
i was trying to do a piece of code to work for hours and when i wrote
ios::out | ios::in as a second parameter to this output file stream my code worked and the stream wrote the data to the file a wanted,whereas before it hasn't happening
Why an output file stream needs ios::in and ios::out to write to a file?
This is a striped down version of my code
ifstream read ;
ofstream writeout ;
read.open("data.txt") ;
somefunction(num , ID , price , size , read );
readF.close() ;
do
{
readF.open("data.txt") ;
writeout.open("out.txt" , ios::out | ios::in);
//this function must write data to a file
someotherfunction(writeout , num , ID);
////////CODE//////////
read.close();
writeout.close();
}while(...);
sorry for my bad english