FOPEN(3) Linux Programmer's Manual FOPEN(3) NAME fopen, fdopen, freopen - SYNOPSIS #include FILE *fopen(const char *path, const char *mode); FILE *fdopen(int fildes, const char *mode); FILE *freopen(const char *path, const char *mode, FILE *stream); DESCRIPTION fopen path mode (): r r+ w w+ a () a+ () mode ``b'' ANSI X3.159-1989 (``ANSI C'') POSIX ``b'' Linux( I/O ``b'' Unix ) S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH (0666) umask ( umask(2)) / ANSI C () ( Linux ) fseek fgetpos ( fseek(..., 0L, SEEK_CUR) )(?) ( a mode ) fseek(stream,0,SEEK_END); fdopen fildes. mode ( "r", "r+", "w", "w+", "a", "a+" ) fildes "w" "w+" fdopen fdopen freopen path stream () mode fopen freopen (stderr, stdin, stdout) RETURN VALUE fopen, fdopen freopen FILE NULL errno ERRORS EINVAL fopen, fdopen, freopen mode fopen, fdopen freopen errno malloc(3) fopen errno open(2) fdopen errno fcntl(2) freopen errno open(2), fclose(3) fflush(3) CONFORMING TO fopen freopen ANSI X3.159-1989 (``ANSI C'') fdopen IEEE Std1003.1-1988 (``POSIX.1'') SEE ALSO open(2), fclose(3), fileno(3) man man https://github.com/man-pages-zh/manpages- zh BSD MANPAGE 2002-01-03 FOPEN(3)