So this is more of a logic question opposed to a code question. I am working a project for school and this is the part im stuck on. I have an array of integers that I got from different characters. I can get them into 8bit binary, but than I have to separate them into groups of 6.
Than I have to analyze the groups after. Basically I am making a base64 encoder. I spent about three hours last night messing around with bit wise operators and couldn't for the life of me figure out how to get the grouping right. Could anyone push me in the right direction?
If you can convert them into their binary forms in the form of booleans, consider a std::vector<bool> (which is optimized for this) to hold the bits. Then you can just have nested loops getting six at a time with space in between ;)
Why have you decided that the realization of bitset can not use a character array? Is any requirements in the C++ Standard for the realization of butset?
You guys helped me to a point. Im trying to write my own code in the stuff I know and all that. So I have a vector full of 8bit segments. How would I cast or transfer that to a vector of 6bit segments? And what do you think would be the easiest way to do the base64 library? The only way I know would be to do 63 if statements.
Which base 64 do you speak of? There is mathematical base 64 with digits 0-9, digits A-Z, digits a-z, and the last two digits of your choice, then there is this other base 64: http://en.wikipedia.org/wiki/Base_64
Also, I recommend not using bitsets at all for this. It is far easier without them.