i'm trying to make a code can convert an image to binary(o-1) and it worked well but there are many symbols (ASCII characters) missed in the result of my code while when i open the image in hex editor i find the full image converted and i find these characters converted too , and when i tried to make a counter beside every binary comes out , i noticed the counter stops before the missed character and starts again after passing it. here is my code..
#include <string>
#include <bitset>
#include <iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream file("E:\\2.jpg");
string myString;
ofstream fout("E:\\mnmn.txt");
while(file>>myString)
{
for (size_t i = 0; i < myString.size(); ++i)
{
fout <<i <<"-"<< bitset<8>(myString.c_str()[i])<<endl;
}}
return 0;
}
the result comes out like:
0-11111111
1-11011000
2-11111111
3-11100000
4-00000000
5-00010000
0-01001010 \\passed 00001001 character and started the counter from the beginig
1-00000000
etc...
Thank you in advance for anyone would help.