   Loop through every possible combination of array
  i know the title is a bit confusing, but i can't express my problem somehow else.what i want to do is to create an array, and that a loop ( unfortunately it's some loops inside other loops ) creates every possible combination of this array.(example for a binary array of a size of 3):000010011100110111somehow my logic isn't working. i just don't know how i can solve this problem.i have problems with creating the major loop. perhaps you can help me?( i wan't to create a generator, wich then creates every possible combination for a string of specified length, to compare thei checksum with the checksum of another string, to see how my checksum gen is working )   
  The basic solution is simple, I think.For a general n dimensions array of size A1 x A2 x ... x An,the algorithm would be:For each A1    For each A2   ...  For each AnFor your binary array you'd get:000001010011100101110111(btw notice the pattern of 1 a 0 in each column, it is interesting I think and you can generalize it)So how come you got a problem with that ? Would you lice to post some sample code ? Because I think te basic principle is quite simple and you should be int with it.Edit: after thinking about it, what I said above may not fit you needs if you dont know the array size (your string length)  at compile time. I'll think about that issue...Regards,Janta   ;  Your example is wrong.000001010011100101110111are all combinations of a 3 bit array.Essentially all you do is count up.   ;  You could use a recursive function, one iteration of which processes one character of the string and then lets it's child invocation process the string starting from the next character, until the end of the original string is achieved.Note that to check and/or store each and every variation of even a 20-character string is highly impractical in terms of both memory and processing power for ordinary household computers.   ;  Your logic isn't working because your specifications are off. You haven't shown combinations at all.Say I have three symbols, a, b and c. I can permutate them in a number of ways, for a given sequence length without repetition: abc, acb, bac, bca, cab, cba. There are standard formulas to compute this, the permutation nPk.If I add an additional symbol, d, then state that I wish to obtain permutations for a number of elements from the original symbol list, say 2, less than or equal to the size of the list, then I am seeking the combination nCk.The Standard C++ Library's <algorithm> header includes a function called next_permutation. Unfortunately, it does not include a next_combination.   ;  @jantathe problem is, that i tried to make the algorithm for a string of general size.i can go through examples in my mind, but i just couldn't find a way to do this for an unspecified length.while( sign < 255 ){ for(int z = 0; z < sign; z++){for(int i = 0; i < 256; i++)String2[z]++;}sign++; }}this is my first attempt but it doesn't really solve my problem because it just loops every character for each field, but not every combination.@trap sorry, you're right, after a short reflection, i noticed that the possible outcomes are 2^3 wich is 8 not 6 -.-@nik2i think i know what you mean, i'll try this one out.but you're right, this really demands cpu and memory, but don't want to store each checksum in the end, just compare them with the other one and then move further@Oluseyii had this kind of stuff in school once, but i need more time to go through the stuff on your links, i'll read it. but why do you mean i haven't showed combinations? i know they weren't all of them, but they are the same numbers, arranged in another order...   ;  hacky way to do it (for strings of length <= 8):char test[9];test[8]=0;unsigned long long* x = (unsigned long long*) test;*x=0;do{dosomething(test);(*x)++;}while(*x!=0);;char const minimumValidCharacterValue = 'a';char const maximumValidCharacterValue = 'z';std::string string(specifiedLength, minimumValidCharacterValue);bool overflow = false;while (!overflow){std::string::reverse_iterator character = string.rbegin();do{++*character;overflow = *character > maximumValidCharacterValue || *character <= minimumValidCharacterValue;if (overflow){*character = minimumValidCharacterValue;}++character;} while (overflow && character != string.rend());}Can be simplified if either or both ends of the valid character value range coincide with the ends of the range of the underlying type.The theory is simple.  Increment that last character.  If it overflows then increment the last-but-one character.  If that overflows then increment the last-but-two character, etc.  After each step a new value is formed and we have reached the end when the first character overflows back to the beginning again.Σnigma   ;Quote:Original post by OluseyiYour logic isn't working because your specifications are off. You haven't shown combinations at all.Say I have three symbols, a, b and c. I can permutate them in a number of ways, for a given sequence length without repetition: abc, acb, bac, bca, cab, cba. There are standard formulas to compute this, the permutation nPk.If I add an additional symbol, d, then state that I wish to obtain permutations for a number of elements from the original symbol list, say 2, less than or equal to the size of the list, then I am seeking the combination nCk.The Standard C++ Library's <algorithm> header includes a function called next_permutation. Unfortunately, it does not include a next_combination.I think he needs neither of those. Unfortunately english is not my tongue and it is somehow beyond my skills to explain this with appropriate mathematical words, but I'll give it a try.Let E  = {a, b, c, .., x, y, z };#E = 26 ( means that E has 26 elements)What Shadowman needs, is all the elements of F where F would be:F = E^n (F is all the strings of length n, using only elements of E, ie no white spaces, but you can add a white space to E if needed)In ths case the solution is much easier since the number of elements in F is#F = (#E)^n = 26^n (so be carfull because this grows very very fast :) )What you want to do if i understood corectly, is get all possible elements of F, which are all  possible n-length strings.I think an easy way for that would be to make an analogy with decimal integer numbers. What are they in fact ? just arrays of { 0, 1, .., 9}And how do you get all combinations of numbers of, say, 3 digits ?> You count.So how about you do the same things with a string ? it would not be much more difficult. I give you this example (it might have mistake because I'm typing it directly here in the message editor)class IncrementableString{public:    IncrementableString(int length); // malloc a char[length] and init to "aaaaa".    bool Increment(); // or overload ++ ;)    char* GetString(); // returns myStringprivate:    char* myString;    int myLength;    bool IncrementDigit(int digit);}bool IncrementableString::Increment(){    return IncrementDigit(0);}bool IncrementableString::IncrementDigit(int digit){    if( digit < myLength )    {   if( myString[digit] < 'z' )   {   myString[digit]++;   return true;   }   else   {  myString[digit] = 'a';  return IncrementDigit(digit + 1);   }    }    else    {   return false;    }}void main(){    IncrementableString s(200);    do    {   cout << s.GetString() << endl;    } while( s.Increment() );   }Quick and dirty but you got the basic principle.Regards,JantaEDIT: Arghhh Enigma you're way too fast :p damn you :)   ;  google: anagram   