summaryrefslogtreecommitdiff
path: root/reference/CPLUSPLUS/EXAMPLES/io2.cc
diff options
context:
space:
mode:
Diffstat (limited to 'reference/CPLUSPLUS/EXAMPLES/io2.cc')
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/io2.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/reference/CPLUSPLUS/EXAMPLES/io2.cc b/reference/CPLUSPLUS/EXAMPLES/io2.cc
new file mode 100644
index 0000000..53484a7
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/io2.cc
@@ -0,0 +1,27 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <fstream.h> // ifstream, ofstream, fstream
+#include <iostream.h> // cin, cout
+
+main()
+{
+ char buf[255];
+ char File[]="tempfile";
+
+ cout << "Please enter a string => "; // O/P to STDOUT (screen).
+ cin >> buf; // Read from STDIN (keyboard).
+
+ cout << " Writing string to " << File << "\n";
+
+ ofstream fp(File); // Open file for O/P
+ fp << buf << "\n"; // Write to the file.
+
+ // ... File is closed at program end.
+}