0% found this document useful (0 votes)
19 views1 page

Files - C

The document contains C++ code to read lines from an input file and write them to an output file while also printing to standard output.

Uploaded by

python
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Files - C

The document contains C++ code to read lines from an input file and write them to an output file while also printing to standard output.

Uploaded by

python
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <bits/stdc++.

h>
using namespace std;

int main() {
string line;
ifstream input ( "input.txt" );
ofstream output ("output.txt");

/*if (output.is_open()) {
if (input.is_open()){
while (getline (input,line)) {
output << line << endl;
cout << line << endl;
}
input.close();
}
else {
cout << "input.txt cannot be opened!\n";
}
output.close();
}
else {
cout << "output.txt cannot be written to!\n";
}*/
while (getline (input,line)) {
output << line << endl;
cout << line << endl;
}
input.close();
}

You might also like