On Thu, Aug 21, 2008 at 3:40 PM, mano M <[EMAIL PROTECTED]> wrote: > Hi, > I am trying to copy a file using c++ library ; It works fine .But If I don't > have enough space to copy , it copies portion of file and exits without > showing any error or exception > > Code looks like > > ifstream infile(fileName); > ofstream outfile(BkpFname); > outfile << infile.rdbuf(); //How can find failure of this statement
Use a temporary variable and check for failure: http://www.cplusplus.com/reference/iostream/ios/rdbuf.html // redirecting cout's output #include <iostream> #include <fstream> using namespace std; int main () { streambuf *psbuf; ofstream filestr; filestr.open ("test.txt"); psbuf = filestr.rdbuf(); // you'd check this successfully completed a read cout.rdbuf(psbuf); // then check that this successfully completed a write. cout << "This is written to the file"; filestr.close(); return 0; } -- PJH http://shabbleland.myminicity.com/ind
