#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <crypt.h>
int main(int argc, string argv[])
{
if(argc > 2){ printf("too many arguments\n"); return 51; }
if(argc < 2){ printf("too few arguments\n"); return 50; }
if(strlen(argv[1]) > 4){ printf("Password is greater than 4 characters\n"); return 52; }
if(argc == 2) //make sure there are enough args
{
string hash_guess = "A";
while(crypt(hash_guess, "50") != argv[1]) //while answer not correct
{
while(hash_guess[0] <= 'Z' && hash_guess[0] >= 'A')
{
hash_guess[0] = hash_guess[0] + 1;
printf("%s", hash_guess);
}
}
}
}
I am trying to increment letter by letter through a word, so it would go a then b then c until z then it will go aa, ab, ac, ad.... then ba bb bc bd... then za... zz... zzz. I'm starting with one letter, but I get error "segmentation fault"