I have a problem with I/O streams in c++. I have to write a program which read data from file and writes it into another file. Command in CMD should be like: "program < file1 > file2". The names of the files should be provided by the user (could be random).I've written a code but it's not correct. I don't know how to redirect stream to file using command "> file2". What I can change in my code to make it work? Can somebody help me?
Код: Выделить всё
#include
#include
#include
int main() {
std::string input_line;
while (std::getline(std::cin, input_line)) {
std::ofstream output_file("file2.txt", std::ios::app);
if (!output_file.is_open()) {
std::cerr
Источник: [url]https://stackoverflow.com/questions/78133486/c-input-output-stream[/url]