I am writing a driver and using fwrite for logging data to a file. I have a logger class which uses fwrite. Now i am passing the pointer and size but the data written into the file seems to be 161 bytes while I pass 160 as the length (call by ref as an arg of the function of the logger class - a fwrite wrapper). In 5/6 ases, the 160bytes are written but in 1 case 161 bytes are written. I am not able to understand how.
Additional info: I am on Win7. Using VS/DDK, Using Notepad++ hex editor to view the data, data is written with '\n' as separating the data tags so that it can be seen in notepad also.
code:
size_t AbhiLogger :: addData(const void * data, size_t length) {
if(m_pFile== NULL)
return E_BADFILE;
return fwrite(data, 1,length, m_pFile);
}
AbhiLogger encapsulates the path, filename and extensions along with the filehandle. The reason is that you can change the name/extn/path any or all and it will associate the handle to newly opened after closing the previous file.