Code: DPError dpResult = DPMS_SUCCESS; FILE *hFile = NULL; BOOL bRetValue = FALSE; CDPString dpFilePath; size_t size = 0; char *tBuffer = new char[m_sFileSize]; tBuffer = m_pszStream; dpFilePath = m_dpFilePath; dpFilePath += "\\"; dpFilePath += m_dpFileName; if(hFile == NULL) { hFile = fopen(dpFilePath, "a+"); if(hFile) { size = fwrite(m_pszStream, m_sFileSize,sizeof(char), hFile); if(size < 0) { dpResult = DPMS_FILE_WRITE_ERROR; } fclose(hFile); } else { dpResult = DPMS_FILE_OPEN_ERROR; } } return dpResult; } in this code i had made size of file as member variable but i want it to access through the char* type of buffer. this char* could contain any type of data like binary string so the size should be for binary data also.