?
Solved

fastest method to make a wordlist.

Posted on 2004-10-20
7
Medium Priority
?
318 Views
Last Modified: 2006-11-17
Hi,

1)I want to make a wordlist with all possible words (a-zzzzz ; for example).  (the same as here: http://www.apocalypseonline.com/security/tools/redirect.asp?red_tool=dictmake.zip )
What is the fastest way to do this (I allready made the part which writes to the disk): finding the "next in line" (for example : if you have a the "next" function should give b, if you have zz, it should give aaa).
2)If you do a "typedef special_char char"->you make a type "special_char" which is exactly the same as a char;
and you want tonoverload the operator++ for special_char's, is it also overloaded for char's in that case? If so, what should you do to make that it is only overloaded for special_char's and not for char's ??


Thanks in advance.
0
Comment
Question by:Kappa_Alfa_Kappa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 1

Expert Comment

by:gugario
ID: 12358971
You would have to make a second class if you wanted a separate operator.  Typedefing simply means "this expression now is the same as this other one".  But you don't need overloaded operators for that problem, you could do this:

char increaseChar (char value)
{        
    if  (value != ' z' ) return ( char (value + 1) );
    else return 'a';
}

string getNext ( string current )
{
         int i = current.size()-1;   //start at last
         while ( 1 )
         {
                   if (i == -1) //got to the end, and it's all "a's now"
                   {
                            current = "a" + current;
                            break;
                   }
                   current[i] == increaseChar(current[i]);
                   if (current[i] != 'a')  break;  //you didn't overflow.
           }
           return current;
}
             
             





0
 

Author Comment

by:Kappa_Alfa_Kappa
ID: 12363834
Thanks for your code. I tried it.


/////
#include <windows.h>
#include <iostream>
using namespace std;

char increaseChar (char value);
char * getNext ( char * current );
#define MAXLEN 10
int main(int argc, char* argv[])
{
      char  zz[MAXLEN]="ezze";
      for(int i=0; i<20;i++){
            printf(getNext(zz));
      printf("\n");}
      return 0;
}

char increaseChar (char value)
{        
   if  (value != ' z' ) return ( char (value + 1) );
   else return 'a';
}

char * getNext ( char * current )
{
        int i = strlen(current)-1;   //start at last
        while ( 1 )
        {
                  if (i == -1) //got to the end, and it's all "a's now"
                  {
                           current = "a" ;                                             ;
                           break;
                  }
                  current[i] = increaseChar(current[i]);
                  if (current[i] != 'a')  break;  //you didn't overflow.
          }
          return current;
}
////
but after the "z" it goes to the next in line in ascii->"{" and so on ({|}~&#8962;Çüéâäàåç....).
and when it reaches the last one, the lengthdoesn't increases (doesn't goes from ZZ->AAA)...
I think it has something to do with me replacing the string to char* 's, but I'm not sure....

Thaks again for your help.
0
 

Author Comment

by:Kappa_Alfa_Kappa
ID: 12364135
found it:
it works like that:
////////////
char increaseChar (char value)
{        
   if  (value != 'z' ) return ( char (value + 1) );
   else return 'a';
}

char * getNext ( char * current )
{int k;
        int i =k= strlen(current)-1;   //start at last
        while(1){  


        current[i] = increaseChar(current[i]);
                  if (current[i] == 'a')
                              {      i--;
                                    if(i==-1)
                                          {current[k+1]='a';
                                          }
                              }
                          else break;  
            }
          return current;
}
//////////
Do you happen to see severe errors??? (I'm only a beginner).

Thanks.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Kappa_Alfa_Kappa
ID: 12364354
hmmm.... sorry but it was wrong after all.
here is my current code:
/////

char * getNext ( char * current )
{int k;
        int i =k= strlen(current)-1;  

        while(1){  
        current[i] = increaseChar(current[i]);
                  if (current[i] == 'a')
                              {      i--;
                                    if(i==-1)
                                          {current[k+1]='z';
                                          i=strlen(current)-1;
                                          }
                              }
                          else break;  
            }
          return current;
}
//////
which gives:
....  x       y       z       ba      bb      bc ....
.... zy      zz      aba     abb     abc     abd ....

Do you know what is wrong with it ??

Thanks.
0
 
LVL 1

Expert Comment

by:gugario
ID: 12364775
i'm taking a look right now... i'll get back to you shortly!
0
 
LVL 1

Accepted Solution

by:
gugario earned 500 total points
ID: 12365157
Ok, that's not too bad...
change:
                           if(i==-1)
                                   {current[k+1]='z';
                                   i=strlen(current)-1;
                                   }
to:
                            if(i==-1)
                                   {current[k+1]='a';
                                   break;
                                   }

Do you understand why?  For instance, if the initial string was 'zzz', by the time it gets to i = -1, it would be 'aaa', so all we do is add the extra 'a' to the end, and we get "aaaa"....
0
 

Author Comment

by:Kappa_Alfa_Kappa
ID: 12367051
That works indeed. When I see it I understand why ( If I do it really slow with an example...).

Thanks a lot for all your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question