0

Standart input stream redirection (C++)

So I've heard it is possible to redirect the input stream to file for example. How can I do so? I've tried writing #include <iostream> #include <fstream> .....*code*..... ofstream file(data.txt); cout = file; cout << "*data*"; But it didn't compile because of line "cout = file", where it says that operator = is private. I am sure it can be done in a simular way, but I don't now how exactly... Help me please.

1st Dec 2019, 6:05 PM
Misha Rogoza
Misha Rogoza - avatar
3 odpowiedzi
+ 1
Oh, my bad. I meant output. Thank you for your answers! rdbuf function also works really good.
1st Dec 2019, 7:15 PM
Misha Rogoza
Misha Rogoza - avatar