2

I would like to use widely known code snippet to copy file:

std::ifstream src("in");
std::ofstream dest("out");

dest << src.rdbuf();

The question is: how to properly check if copying succeded?

I thought that checking the value of (src && dest) is ok, but it fails in case of empty source file.

Mati
  • 61
  • 6
  • 3
    Well, you could ensure the source file isn't empty first. I know this sounds like an ugly specialcase, but then again, an empty file is kinda special. – Bartek Banachewicz Jan 12 '15 at 12:40

0 Answers0