Hello All,
Long-time listener, first-time caller.
I've been studying this chat string for a few days to try to get help on Caesar. It has helped me immensely. Y'all seem to be pretty laid-back and more forgiving of ignorance than some of the people on the other forums.
I am ALMOST there. but when I run check50 i get the following errors.
:) caesar.c exists.
:) caesar.c compiles.
:( encrypts "a" as "b" using 1 as key
expected exit code 0, not 1
:( encrypts "barfoo" as "yxocll" using 23 as key
expected "ciphertext: yx...", not "ciphertext: yc..."
:( encrypts "BARFOO" as "EDUIRR" using 3 as key
expected "ciphertext: ED...", not "Cyphertext: EC..."
:( encrypts "BaRFoo" as "FeVJss" using 4 as key
expected "ciphertext: Fe...", not "Cyphertext: Fc..."
:( encrypts "barfoo" as "onesbb" using 65 as key
expected "ciphertext: on...", not "ciphertext: oc..."
:( encrypts "world, say hello!" as "iadxp, emk tqxxa!" using 12 as key
expected "ciphertext: ia...", not "ciphertext: ic..."
:) handles lack of key
:) handles non-numeric key
:) handles too many argumentsmy code is as follows, thanks in advance.
int main(int argc, string argv[])
{
if(argc == 2)
{
for(int key = 0; key < strlen(argv[1]); key++)
{
if(isdigit(argv[1][key]))
{
}
else
{
printf("Usage: ./caesar key\n");
return 1;
}
}
}
else
{
printf("Usage ./caesar key\n");
return 1;
}
int keynum = atoi(argv[1]);
string plntxt = get_string("Plaintext: ");
char len = strlen(plntxt);
for(int p = 0; p < len; p++)
{
int cypher;
if(islower(plntxt[p]))
{
if((cypher = (plntxt[p] + keynum - 97) % 26))
{
printf("cyphertext: %c", cypher + 97);
}
}
else if(isupper(plntxt[p]))
{
if((cypher = (plntxt[p] + keynum - 65) % 26))
{
printf("Cyphertext: %c", cypher + 65);
}
}
else if(!isalpha(plntxt[p]))
{
printf("%c", plntxt[p]);
}
}
printf("\n");
return 1;
. ¦3<RELATIVISM
"\=-"?
. ¦3<RELATIVISM
what would be the mistake Im doing where
. ¦3<RELATIVISM
Anupam Srivastava (Gitter):