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

test.c « fmode « samples « mingw « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f19e7e0ec459fe1dee52f84317123e4aca44c20e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
}