Share via


Commit-To-Disk Constants (Windows CE 5.0)

Send Feedback

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

These Microsoft-specific constants specify whether the buffer associated with the open file is flushed to OS buffers or to disk.

The mode is included in the string specifying the type of read/write access ("r", "w", "a", "r+", "w+", "a+").

#include <stdio.h>

Remarks

The commit-to-disk modes are as follows:

  • c
    Writes the unwritten contents of the specified buffer to disk.

    This commit-to-disk functionality only occurs at explicit calls to the fflush or the _flushall function.

    This mode is useful when dealing with sensitive data. For example, if your program terminates after a call to fflush or _flushall, you can be sure your data reached the OS's buffers. However, unless a file is opened with the c option, the data might never make it to disk if the OS also terminates.

  • n
    The n mode is the default.

    Writes the unwritten contents of the specified buffer to OS buffers.

    The OS can cache data and then determine an optimal time to write to disk.

    Under many conditions, this behavior makes for efficient program behavior. However, if the retention of data is critical (such as bank transactions or airline ticket information) consider using the c option.

    Note   The c and n options are not part of the ANSI standard for fopen, but are Microsoft extensions and should not be used where ANSI portability is desired.

See Also

fopen

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.