unoriginal,
Thanks for your explanation.
Well, as a beginner, I'm uncertain about almost everything, but I think I got what you did.
Let me give you a real example to clarify what I really need to do:
I have a bitset with some bits turned on representing combinations of numbers.
Each element of the combination is represented by the position of each bit into the bitstring (right-to-left order)
ex.: 10010110 = 02 03 05 08
1 2 3 4 5 6 7 8 9 10 11 12 13
|
bitset<32> bitcombinations;
// Populating the bitset
bitcombinations.reset();
for (int i = 0; i <= 10; i++) {
bitcombinations.set(i,true);
}
cout << bitcombinations << endl; // 00000000000000000000001111111111
|
My question is, how to covert this bitstring into a "string combination" concatenating the position's values formatted by 2 digits?
The code would be:
1 2 3 4 5 6 7 8 9 10 11 12
|
for (int i = 0; i < 32; i++) {
if (bitcombinations.at(i)) {
// pseudo-code:
//combstring = combstring & " " & i + 1;
}
}
cout << combstring << endl; // the output should be: "01 02 03 04 05 06 07 08 09 10"
|
So unoriginal, how would be the proper way to construct such strings? Should I use string.h and stdlib.h?
I feel that I did not get how the things works in C/C++ yet because I'm still with the VB's concept in my mind. If you are also a VB programmer, I'm sure you know what I mean :)
But thank you, I think I already found some answers based on your explanations.
Regards,
equinoX