bea966c0d9
(MINGW_OBJS): Add txtmode.o. (SRCDIST_FILES): Add txtmode.c binmode.c. crt1.c: Don't include fcntrl.h, stdlib.h. (_fmode): Declare, without dllimport attribute. (__p__fmode): Declare access function for dll's _fmode. (_mingw32_init_fmode): Sync dll _fmode with staticly linked _fmode for app. * txtmode.c: New file. * binmode.c: New file. * samples/fmode/test2.c: New file. * samples/fmode/jamfile: Add test2.exe target.
38 lines
801 B
C
38 lines
801 B
C
/*
|
|
* 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);
|
|
}
|
|
|