Share via


File Read/Write Access Constants (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Global Constants

These constants specify the access type ("a", "r", or "w") requested for the file.

Both the translation mode ("b" or "t") and the commit-to-disk mode ("c" or "n") can be specified with the type of access.

#include <stdio.h>

Remarks

The access types are as follows.

  • "a"
    Opens for writing at the end of the file (appending); creates the file first if it does not exist.

    All write operations occur at the end of the file. Although the file pointer can be repositioned using fseek, it is always moved back to the end of the file before a write operation is carried out.

  • "a+"
    Same for "a", but also allows reading.

  • "r"
    Opens for reading. If the file does not exist or cannot be found, the call to open the file fails.

  • "r+"
    Opens for both reading and writing. If the file does not exist or cannot be found, the call to open the file fails.

  • "w"
    Opens an empty file for writing. If the file exists, its contents are destroyed.

  • "w+"
    Opens an empty file for reading and writing. If the file exists, its contents are destroyed.

When the "r+", "w+", or "a+" type is specified, reading and writing are allowed (the file is said to be open for "update").

However, when you switch between reading and writing, there must be an intervening fflush, fsetpos, or fseek operation.

The current position can be specified for the fsetpos or fseek operation.

See Also

fflush | fopen | fseek | fsetpos

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.