I am using IBX cplex solver in my C++ program. by default, it prints the solve output into console. But, i wanted this solver output as a string, which can later be used for logging or cout. To achieve this, i used the below code snippet (with setOut function provided by IBM Cplex), but it prints nothing. Please advise me what would be the correct way to achieve this?
//Other code stuffs to initialise cplex solver and model
std::ostringstream ss("");
_cplex.setOut(ss); //_cplex is an instance of IloCplex
std::cerr << ss.str() << std::endl; // Tried ss.rdbuf() also, didn't help
However, It can write the output content into a file with the below code,
//Other code stuffs to initialise cplex solver and model
std::ofstream of("dummy.txt"); //_cplex is an instance of IloCplex
_cplex.setOut(of); //Write successfully to the file dummy.txt