Chapter Contents |
Previous |
Next |
fopen |
Portability: | ISO/ANSI C conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
IMPLEMENTATION | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <stdio.h> FILE *fopen(const char *name, const char *mode);
DESCRIPTION |
The
fopen
function opens a file and returns a pointer to the associated
FILE
object. The
name
argument is the external name (sometimes
called a pathname) of the file to be opened. Its form is system dependent. The
mode
argument is a string defining how the file
will be used. For more information about open mode values, see Open modes.
RETURN VALUE |
The
fopen
function returns a pointer to a
FILE
object associated with the named file. If the file cannot be opened,
a
NULL
value is returned.
IMPLEMENTATION |
At most, 256 files can be open at one time, including the three standard files.
EXAMPLE |
This example opens for
a
the second time to add an additional line to the file:
#include <stdio.h> main() { FILE* test; int c; float a; test = fopen("tso:TEST", "w"); puts("Enter maximum speed limit in miles:"); scanf("%d", &c); fprintf(test, "Maximum speed limit is %d miles/hour.\n", c); fclose(test); a = 1.619 * c; test = fopen("tso:TEST", "a"); fprintf(test, "\n In km/h, the maximum speed limit is %f\n", a); fclose(test); }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.