Search code examples
cfopenstdio

About binary modes in fopen


I already read the C++ Reference about fopen access modes, but I don't understand the difference between "a+b" and "ab+", or between "w+b" and "wb+".


Solution

  • The ordering of the mode flags is not relevant. So ab+ and a+b are equivalent.

    The b flag opens the file in binary mode, which disables the special handling of certain characters in DOS and Windows, but has no effect on macOS and POSIX systems.