C++ string.clear() doesn't empty my string -


so problem is, code:

string num = "00101011110011100001"; string quartett; int = num.length() - 1; while (i > 0) {     quartett.clear();     quartett = num.substr((i - 3), i);     cout << quartett << endl;     = - 4; } 

prints out this:

0001 11100001 11001110000 1011110 001 

actual output should be:

0001 1110 1100 1011 0010 

the thing don't have idea why. hope can me , in advance.

the second argument substr() length, not index. should be:

quartett = num.substr((i - 3), 4); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -