так попробуйте
Код:
#include <iostream>
#include <fstream>
#include <windows.h>
#include <stdio.h>
using namespace std;
int main()
{
HANDLE hAppend;
DWORD dwBytesRead=10, dwBytesWritten=10, dwPos=0;
hAppend = CreateFile(TEXT("inp.txt"),
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hAppend == INVALID_HANDLE_VALUE)
{
printf("Could not open inp.txt.");
return 0;
}
LockFile(hAppend, dwPos, 0, dwBytesRead, 0);
int k=0;
while(k!=1)
{
cin>>k;
}
UnlockFile(hAppend, dwPos, 0, dwBytesRead, 0);
return 0;
}