#includeusing namespace std; int main() { cout << "Hello World!" << endl; if (cout.good()) { cout << "Stream is good." << endl; } else { cout << "Stream is not good." << endl; } return 0; }
Hello World! Stream is good.
#include#include using namespace std; int main() { ofstream file("example.txt"); if (file.is_open()) { file << "This is an example."; if (file.good()) { cout << "File stream is good." << endl; } else { cout << "File stream is not good." << endl; } file.close(); } else { cout << "Unable to open file."; } return 0; }
File stream is good.The package library used in these examples is the C++ Standard Library (STL) which provides a set of useful functions and classes for C++ programming.