Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Find words with a bit difference ( I think thats what it was meant to do )
- // By image28 From 2004
- //
- // Compile with gcc filename.c -o executable-name
- // run with ./execuatable-name [wordlist file/dictionary 'words' file]
- #include "defines.h"
- #include "strings.h"
- int stringlen(char string[1000]);
- int stringcompare(char string[1000], char string2[1000]);
- int main(int argc,char *argv[])
- {
- FILE *input;
- FILE *output;
- char out[1000];
- long count=0;
- int occurs=0;
- int done=0;
- int d=0;
- int e=0;
- char current_word[65535][100];
- strcpy(out,argv[1]);
- strcat(out,".out");
- if ( ( input=fopen(argv[1],"rb") ) == NULL ) exit(-1);
- output=fopen(out,"wb");
- while ( ! feof(input) )
- {
- count=0;
- fscanf(input,"%s",current_word[0]);
- printf("%s\n",current_word[0]);
- do
- {
- count++;
- fscanf(input,"%s",current_word[count]);
- printf("%s %d\n",current_word[count], stringlen(current_word[count]));
- }while ( ( stringcompare(current_word[0],current_word[count]) == 1 ) && ( ! feof(input) ) );
- printf("COUNT %d\n",count);
- if ( count > 1 )
- {
- for(d=0;d<count-1;d++)
- {
- for(e=d+1;e<count;e++)
- {
- if ( stringcompare(current_word[d],current_word[e]) == 0 )
- occurs++;
- }
- if ( ! occurs )
- fprintf(output,"%s\n",current_word[d]);
- }
- fprintf(output,"\n");
- }
- }
- if ( count > 1 )
- {
- for(d=0;d<count;d++)
- fprintf(output,"%s\n",current_word[d]);
- fprintf(output,"\n");
- }
- fclose(input);
- fclose(output);
- return(0);
- }
- int stringlen(char string[1000])
- {
- int count=0;
- while ( string[count] != '\0' )
- {
- count++;
- }
- return(count);
- }
- int stringcompare(char string[1000], char string2[1000])
- {
- int count=0;
- int d=0;
- for(d=0;d<stringlen(string);d++)
- {
- if ( string[d] != string2[d] )
- {
- count++;
- }
- }
- return(count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement