Initial revision
[LeanCalc.git] / help / freopen
1 NAME
2     freopen - close (if necessary) and reopen a filestream
3
4 SYNOPSIS
5     freopen(fs, mode) or freopen(fs, mode, filename)
6
7 TYPES
8     fs          open or closed file stream
9     mode        one of the strings "r", "w", "a", "r+", "w+, "a+"
10     filename    string
11
12     return      null or error value
13
14 DESCRIPTION
15     With two arguments, this function closes the file stream fs and
16     attempts to reopen it with the specified mode.  A non-null value
17     is returned only if the attempt fails.
18
19     With three arguments, fs, if open, is closed, and an attempt is made to
20     open the file with the specified name and assign it to the stream
21     fs.  A non-null value is returned only if the attempt fails.
22
23 EXAMPLE
24
25     > f = fopen("/tmp/junk", "w")
26     > fputs(f, "Leonard Euler")
27     > freopen(f, "r")
28     > fgets(f)
29             "Leonard Euler"
30     > !chmod u-w /tmp/junk
31     > freopen(f, "w")
32             Error 10013
33
34 LIMITS
35     none - XXX - is this correct?
36
37 LINK LIBRARY
38     none - XXX - is this correct?
39
40 SEE ALSO
41     errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
42     fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt
43