So the problem is, that this code:
string num = "00101011110011100001";
string quartett;
int i = num.length() - 1;
while (i > 0) {
quartett.clear();
quartett = num.substr((i - 3), i);
cout << quartett << endl;
i = i - 4;
}
Prints out this:
0001
11100001
11001110000
1011110
001
actual output should be:
0001
1110
1100
1011
0010
The thing is I don't have any idea why. I hope you can help me and thanks in advance.
quartettwith thesubstring()call, theclear()is pointless. It cannot be the reason for the problem.