The fopen Function
FILE *fopen(char *name, char *mode);
- attempts to open a stream to a file called
name
- typical modes:
"r" read, "w" write, "a" append
- returns
FILE* if successful, NULL if not
- on open for reading ...
- failure if file does not exist
- failure if user does not have read permission
- on open for writing ...
- file is created if it does not already exist
- file is truncated if it does exist
- failure if no write permission on file or directory
- for append: output added after end of existing file
|