By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,433 Members | 1,844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,433 IT Pros & Developers. It's quick & easy.

binary file to CString

P: n/a
given the following base64_encode function, I will read bytes from a
file and encode the binary data into a single line CString;

but something wrong with the following code with errors!

std::string base64_encode(unsigned char const* bytes_to_encode,
unsigned int in_len) {

#define BYTE unsigned char
int size;
BYTE* buffer;
std::ifstream inputFile("C:\\test.bin", std::ios::in |

// open the binary file to read
if (inputFile.is_open())

inputFile.seekg(0, std::ios::end);
size = inputFile.tellg(); // size of the file

buffer = new BYTE[size];, size);

// encode binary data into a Base64 string
std::string data = base64_encode(buffer, size);
// convert std::string to CString
CString st = CString(data);

Nov 19 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.