This is possible in C11 or directly using the low-level OS API functions.
If you use C11, fopen allows you to open the file in "wx" mode.
Otherwise, on Linux, you must pass both O_CREAT and O_EXCL to the open(3) function. Or on Windows, go CREATE_NEW to the dwCreationDisposition parameter of the CreateFile() function.
EDIT: I initially overlooked the fact that the open function was updated to C11.
Matthieu M.
source share