WriteFile/ReadFile repeat last lines
Hi
Code:
do
{
bReadSuccess = ReadFile( hFile, strBuffer, sizeof(strBuffer), &nRead, NULL);
bWriteSuccess = WriteFile( hFile2, strBuffer, sizeof(strBuffer), &nWrite, NULL);
}while(bReadSuccess && bWriteSuccess && (nRead > 0));
a.txt's last line is:
315614,05r re regf
b.txt's last lines are:
315614,05r re regf
315614,05r re regf
315614,05r re
What is wrong with that loop?
Thanks.
Re: WriteFile/ReadFile repeat last lines
nRead doesn't has to be sizeof(strBuffer) if the buffer isn't fully filled, this probably creates the wierd lines. You are writing more that you read.
Re: WriteFile/ReadFile repeat last lines
Understood.
Solved it:
Code:
do
{
bReadSuccess = ReadFile( hFile, strBuffer, sizeof(strBuffer), &nRead, NULL);
bWriteSuccess = WriteFile( hFile2, strBuffer, nRead, &nWrite, NULL);
}while(bReadSuccess && bWriteSuccess && (nRead > 0));
Thanks