I have a requirement, I need to use printf and cout to display the data into console and file as well. For printf I have
printf
cout
console and file
If you have another stream buffer, you can just replace std::cout's:
std::cout
std::cout.rdbuf(some_other_rdbuf);
See http://en.cppreference.com/w/cpp/io/basic_ios/rdbuf.