Re: [Dev-C++] Producing a endless list of strings.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: manilius <man...@gm...> - 2003-07-31 08:11:21
|
Hi
=20
> Ok, the idea was to create all the possible combinations
> (up to 100
> characters long) using all the avalible characters in the
> ascii character
> set from 32 (space) to 126 (~) inclusive. When we try to
> increment '~' we
> end up getting a space and we increment the next character
> in the string and
> applying the same overflow rule.
Okay, that would be one way to do it, but it does involve a lot of =
string
manipulation (check a character and change it) which is not needed with
recursion. Is there a special reason you want to use your "overflow
algorithm"?
If you want more characters with the recursion example I sent you, just =
add
them to the character table:
for( int i=3D0; i<92; i++) CharacterTable.push_back(' '+i);
should include all characters you want.
If you need zero-terminated strings, you can use the function c_str() of =
the
std::string class to create them.=20
But again: There is no way to create a list of all possible strings with =
the
length of 100. You have
(# of possible charcters)^length of the string=20
possibilities. This results in a huge number (try calculate 92^100 :)=20
ciao...
...manilius
|