Using crypt() from crypt.h

Viewed 11503

I am doing the week2 pset for CS50. When using the crypt function, the char pointers which point to the ciphertext of any string always point to the last thing I encrypted. For example:

char password[] = "AAAA";
char toCrack[] = "AAzz";
printf("%s\n", password);
printf("%s\n", toCrack);

char *toCrackCiph = crypt(toCrack, "da");
char *passwordCiph = crypt(password, "aa");


printf("%s\n", passwordCiph);
printf("%s\n", toCrackCiph);

toCrackCiph and passwordCiph equal each other, even though their strings are not the same, and neither is the salt.

Am I making a simple pointer error somewhere?

Thanks,

1 Answers
Related