Code:void CFileMgm::write(string fname, solutions databox) { file1.open (fname.c_str(), ios::out); if (file1.is_open())//if(file)+ { file1<<"Population Size is : "; file1<<databox.pop_size; file1<<"Crossover Rate is : "; file1<<databox.crossover_rate; file1<<"Mutation Rate is : "; file1<<databox.mutation_rate; file1<<"Maximum fitness is: "; file1<<databox.fitnesses[0]; file1.close(); } else { AfxMessageBox("Unable to open file"); //cout<<"File does not exist"; exit(0); }
i don't know why this code is unable to write any thing in file.
following is onsavedocument function
Code:BOOL CTspGeneticAlgoDoc::OnSaveDocument(LPCTSTR lpszPathName) { string filename = (string) lpszPathName; CFileMgm mydatafile; mydatafile.write(filename,sol); return CDocument::OnSaveDocument(lpszPathName); }




Reply With Quote