char data1[] = ""; int offset = 0; LPTSTR pszString = NULL; LPSTREAM lpStream = NULL; CreateStreamOnHGlobal(NULL, TRUE, &lpStream); StreamStringCopy ((LPSTREAM)lpStream, (LPCTSTR)""); while(of->pread(&data1,1023,offset) > 0){ LPCTSTR tempStr = data1; StreamStringCat ((LPSTREAM)lpStream, tempStr); offset = offset + strlen(data1); } Bitmap bm(lpStream,FALSE); bm.GetHBITMAP(Color.Black, &ret); char* data1 = static_cast (std::malloc (1024 * sizeof (char)); ... std::free (data1); // or try this char data1 [1024] = { 0 }; // Gives you 1024 bytes to write to on the stack