'How do you open a file for shared writing in C?

I only found how to do it in C++ which is somthing like CreateFile(.... FILE_SHARE_READ | FILE_SHARE_WRITE, ....) but found nothing on how to do it in C.



Solution 1:[1]

What you are asking for is not possible in plain ISO C, which only offers the function fopen.

However, on Microsoft Windows, you can call the platform-specific function CreateFile, which offers this feature as an extension. You can use this function also when using the C programming language. It is not restricted to C++. The Microsoft documentation of the Windows API does not distinguish between C and C++, so when it refers to C++, it also means C.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andreas Wenzel