I just wrote the program for cs50 pset2 vigenere problem. It ran perfectly when I tried to run it, with expected output. But on submitting, cs50.me check50 shows that my program does not show the output, when it definitely does.
It runs perfectly. Please help!
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int shift (char c);
int main(int argc, string argv[])
{
if (argc != 2 || !isalpha(argv[1][0]))
{
printf("Usage: ./vignere keyword\n");
return 1;
}
else
{
char key[100];
for(int j=0; key[j] != '\0'; j++)
{
key[j] = shift(argv[1][j]);
}
string text = get_string("Plaintext: ");
printf("ciphertext: ");
int j = 0;
for (int i = 0; text[i] != '\0'; i++)
{
if (j == strlen(argv[1]))
{
j = 0;
}
if (islower(text[i]))
{
printf("%c",(((text[i] + key[j]) - 97) % 26) + 97);
}
else if (isupper(text[i]))
{
printf("%c",(((text[i] + key[j]) - 65) % 26) + 65);
}
j++;
}
printf("\n");
return 0;
}
}
int shift(char c)
{
if (islower(c))
{
c -= 97;
}
else if (isupper(c))
{
c -= 65;
}
return c;
}
This is the link https://cs50.me/submit50/results/deku82/c9a713dbd8b4c5ed00e196906bbd8f3c23437440