fopen - open in exclusive read mode ?

Giganews Newsgroups
Subject: fopen - open in exclusive read mode ?
Posted by:  R.Wieser (addre…@not.available)
Date: Wed, 4 Nov 2020

Hello all,

I've got a small program which rewrites the contents of a textfile.  I'm
using "fopen" for both the source as well as the target file, reading lines
from the first and writing them to the second.

The problem is that when both have the same name the file is destroyed. :-((

To fix that I've been looking for an "exclusive read" open mode (so that
opening the targetfile would error-out).  The thing is that Windows doesn't
seem to offer it :

It does offer an "x" modifier, but that one only works on writing.

I've also found a reference to "flock", but that doesn't seem to be part of
the CRTDLL.DLL on XPsp3 .

How do I use "fopen" (or a similar crtdll function) to get an exclusive read
lock ?

Rudy Wieser