#include //C++ example #include #include using namespace std; int main() { ofstream out1("outfile1"); //overwrite if (!out1) { //if (out1.operator!()) { cerr << "can't open outfile1\n"; return EXIT_FAILURE; } ofstream out2("outfile2", ios_base::app); //append if (!out2) { cerr << "can't open outfile2\n"; return EXIT_FAILURE; } out1 << "hello\n"; out2 << "goodbye\n"; return EXIT_SUCCESS; //Call destructors for out2 and out1. }