My code for substitution appears externally to be working correctly. It takes the key as an argument and prompts the user for the plaintext message. Both uppercase and lowercase keys work, and a mixture of both. The substitution happens correctly and respects upper and lowercase. It can handle very long messages fine.
However check50 is giving me the following errors:
Results for cs50/problems/2022/x/substitution generated by check50 v3.3.7
:) substitution.c exists
:) substitution.c compiles
:( encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key
expected prompt for input, found none
:( encrypts "a" as "z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key
expected prompt for input, found none
:( encrypts "ABC" as "NJQ" using NJQSUYBRXMOPFTHZVAWCGILKED as key
expected prompt for input, found none
:( encrypts "XyZ" as "KeD" using NJQSUYBRXMOPFTHZVAWCGILKED as key
expected prompt for input, found none
:( encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZTEOGXHCIPJSQD as key
expected prompt for input, found none
:( encrypts "This is CS50" as "Cbah ah KH50" using yukfrnlbavmwzteogxhcipjsqd as key
expected prompt for input, found none
:( encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZteogxhcipjsqd as key
expected prompt for input, found none
:( encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key
expected prompt for input, found none
:( does not encrypt non-alphabetical characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key
expected prompt for input, found none
:) handles lack of key
:) handles too many arguments
:) handles invalid key length
:) handles invalid characters in key
:( handles duplicate characters in uppercase key
failed to execute program due to segmentation fault
:( handles duplicate characters in lowercase key
failed to execute program due to segmentation fault
:( handles multiple duplicate characters in key
failed to execute program due to segmentation fault
No matter what I cannot replicate the issues manually, not even the segmentation faults. All of my tests give the intended result. Can someone help me figure out what I missed?
**admin edit to remove solution code **
edit: i just tried to compile in codespace instead of locally and see that it doesn't accept strdup(), even though string.h
is linked at the top and the function is part of the CS50 manual. Could that be causing the issue?