Read a binary file (jpg) to a string using c++
问题 I need to read a jpg file to a string. I want to upload this file to our server, I just find out that the API requires a string as the data of this pic. I followed the suggestions in a former question I've asked Upload pics to a server using c++ . int main() { ifstream fin("cloud.jpg"); ofstream fout("test.jpg");//for testing purpose, to see if the string is a right copy ostringstream ostrm; unsigned char tmp; int count = 0; while ( fin >> tmp ) { ++count;//for testing purpose ostrm << tmp; }