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

test2.c « fmode « samples « mingw « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b7d6b18916c9658a7af108b99a048c3404ca1a98 (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
32
33
34
35
36
37
/*
 * A sample program demonstrating how to use fmode to change the default
 * file opening mode to binary.  Compare this file, which sets _fmode
 * at file level to test.c, which sets the dll variable directly within
 * main.
 * NOTE: Does not change stdin, stdout or stderr.
 *
 * THIS CODE IS IN THE PUBLIC DOMAIN.
 *
 * Colin Peters <colin@fu.is.saga-u.ac.jp>
 * Danny Smith <dannysmith@users.sourceforge.net>
 */

#include <stdio.h>
#include <stdlib.h>	/*  _fmode */
#include <fcntl.h>	/*  _O_BINARY */

#undef _fmode
int _fmode = _O_BINARY;

main ()
{
    
	char* sz = "This is line one.\nThis is line two.\n";
	FILE*	fp;

	printf (sz);

	/* Note how this fopen does NOT indicate "wb" to open the file in
	 * binary mode. */
	fp = fopen ("test2.out", "w");

	fprintf (fp, sz);

	fclose (fp);
}