I am having a problem with reading a jpg file. I want to send the plain text value of the jpg image through a socket, so I opened the file in binary mode, thinking that that would work but it doesn't. This is my code:
system("./imagesnap image.jpg");
ifstream image("image.jpg", ios::in | ios::binary);
char imageChar[1024];
string imageString;
while (getline(image, imageString))
{
for (int h; imageString[h] != '\0'; h++) {
imageChar[h] = imageString[h];
}
send(sock, imageChar, strlen(imageChar), 0);
for (int k = 0; imageChar[k] != '\0'; k++) {
imageChar[k] = '\0';
}
}
And here is my output:
????
As you can see, the file is not being opened in binary mode, or it is but its not working.
Could anyone please help?