I am running check50 but it will not accept my output as correct. For example, one of the conditions needed to be satisfied is:
When I run the code below I obtain the desired output (CAQGON) but according to the image above I do not have an output as noted by the blank space below "Actual Output". I suspect it is because I prompt the user to input the key word directly from the command line when I used "int main (int argc, string argv[])" because when I use get_string() instead, check50 is able to recognize the output. Any help would be appreciate, thanks.
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int shift;
int j;
int main(int argc, string argv[]) //user inputs the string(s) and the last string in argv is designated as the key
{
if (argc > 2) //I dont want to limit user input //isdigit() can only read char not strings
{
int key = strlen(argv[argc - 1]);
for (int i = 1; i < argc - 1; i++)
{
for (j = 0; j < strlen(argv[i]); j++)
{
if (isalpha(argv[i][j]) == 0 && isdigit(argv[i][j]) == true)
{
printf("%c", argv[i][j]);
}
else if (isalpha(argv[i][(j)]) != 0)
{
shift = toupper(argv[argc - 1][j % key]) % 26 - 13;
//shift is for the key and does ! discern betwen upper and lowercase by treating all key as uppercase letters
}
else
{
shift = 0;
}
printf("%c", argv[i][j] + shift);
}
printf(" "); //spacing in between words
}
printf("\n");
}
else
{
printf("./vigenere keyword\n");
return 1;
}
}