13.01.2015 Views

Pensar en C++ (Volumen 1) - Grupo ARCO

Pensar en C++ (Volumen 1) - Grupo ARCO

Pensar en C++ (Volumen 1) - Grupo ARCO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

✐<br />

✐<br />

✐<br />

“Volum<strong>en</strong>1” — 2012/1/12 — 13:52 — page 55 — #93<br />

✐<br />

2.6. Lectura y escritura de ficheros<br />

//: C02:Scopy.cpp<br />

// Copy one file to another, a line at a time<br />

#include <br />

#include <br />

using namespace std;<br />

int main() {<br />

ifstream in("Scopy.cpp"); // Op<strong>en</strong> for reading<br />

ofstream out("Scopy2.cpp"); // Op<strong>en</strong> for writing<br />

string s;<br />

while(getline(in, s)) // Discards newline char<br />

out

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!