Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-02-17 22:38:33 +0300
committerChristopher Faylor <me@cgf.cx>2000-02-17 22:38:33 +0300
commit1fd5e000ace55b323124c7e556a7a864b972a5c4 (patch)
treedc4fcf1e5e22a040716ef92c496b8d94959b2baa /winsup/mingw/samples/fmode/test.c
parent369d8a8fd5e887eca547bf34bccfdf755c9e5397 (diff)
import winsup-2000-02-17 snapshot
Diffstat (limited to 'winsup/mingw/samples/fmode/test.c')
-rw-r--r--winsup/mingw/samples/fmode/test.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/winsup/mingw/samples/fmode/test.c b/winsup/mingw/samples/fmode/test.c
new file mode 100644
index 000000000..f19e7e0ec
--- /dev/null
+++ b/winsup/mingw/samples/fmode/test.c
@@ -0,0 +1,31 @@
+/*
+ * A sample program demonstrating how to use fmode to change the default
+ * file opening mode to binary. NOTE: Does not change stdin, stdout or
+ * stderr.
+ *
+ * THIS CODE IS IN THE PUBLIC DOMAIN.
+ *
+ * Colin Peters <colin@fu.is.saga-u.ac.jp>
+ */
+
+#include <stdio.h>
+#include <fcntl.h> /* Required to get _fmode and _O_BINARY */
+
+main ()
+{
+ char* sz = "This is line one.\nThis is line two.\n";
+ FILE* fp;
+
+ _fmode = _O_BINARY;
+
+ printf (sz);
+
+ /* Note how this fopen does NOT indicate "wb" to open the file in
+ * binary mode. */
+ fp = fopen ("test.out", "w");
+
+ fprintf (fp, sz);
+
+ fclose (fp);
+}
+