Can anyone help me as what is going wrong here? Am not able to allocate memory using malloc...
bReadFile = ReadFile( hConsoleFile, &ReadFileBuffer, MaxCharToRead, &CharsRead, NULL );
You have &ReadFileBuffer
in the call to ReadFile
. You are supposed to pass ReadFile
a pointer to the buffer, not a pointer to a pointer to the buffer.
From the documentation:
lpBuffer [out]
A pointer to the buffer that receives the data read from a file or device.
Since ReadFileBuffer
is a pointer to the buffer, that's what you should be passing.