Not sure what the actual problem is, but maybe you are missing ios::ate so that the file does not get truncated each time you open it, i.e.
file_op2("c:\\arun.txt", ios::out|<strong>ios::ate</strong>);
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
i wan to write into different files......i am using a loop so i wan the name to be generated automatically...and not as in the coding.....if its like in the coding then the classes will be written in 1 file....i wan to be like, when the first class is found i want it to write into a new file maybe test.1 so it continues till the last class is detected..but i wan it in the loop format....i wan the path of the file to be generated automatically with different names so each class will be written inside different files..
Then put the filename together like
<strong>int</strong> counter = 1;
stringstream sstrm;
sstrm << "c:\\file#" << counter << ".txt";
string filename = sstrm.str();
cout << filename;
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
It has to be ...
fstream file_op2(filename.<strong>c_str()</strong>, ios::out);
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395