My programm reads out the first 2 Numbers of a hpgl plotfile, calculates the distance between those coordinates, and writes acordingly to the distance ones and zeros to another file.
Two long rows of 1 and 0 are created, like this:
x: y:
1 1
1 1
1 0
1 0
1 0
1 1
0 1
0 1

Now I would need to collect every 8 digits of either row (x and y)
to create hex numbers according to the binary pattern of the collected byte.

Does anyone have an idea how I could readout every 8 digits of either row?
like
x: 11111100 = FC
y: 11000111 = C7

2. Well, the easiest way would be to build two strings gradually from each row. Then when you have both strings, convert the binary digits to integers and print them in hexadecimal:
Code:
```#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int btod(const char *b);

int
main()
{
char     xdigit;
char     ydigit;
string   x;
string   y;
ifstream in("data.txt");

if (!in) {
cerr<<"Error opening file"<<endl;
exit(EXIT_FAILURE);
}
while (in>> xdigit >> ydigit) {
x.push_back(xdigit);
y.push_back(ydigit);
}
cout<<"x: "<< x <<" = "<< hex << btod(x.c_str()) <<endl;
cout<<"y: "<< y <<" = "<< hex << btod(y.c_str()) <<endl;
}

int
btod(
const char *b
)
{
// You aren't expected to understand this
return *b ? btod(b + 1) + (*b - '0' << strlen(b) - 1) : 0;
}```