I cannot figure out why I received this error. Only the word 'say' in the "world, say hello!" check50 is not ciphering correctly. My current code is below. Any advice will be greatly appreciated!
#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, string argv[])
{
if (argc != 2)
{
printf("Try again!\n");
return 1;
}
string kw = argv[1];
int nkw = strlen(kw);
for (int pkw = 0; pkw < nkw; pkw++)
{
if (!isalpha (kw[pkw]))
{
printf("Try again!\n");
return 1;
}
}
for (int pkw = 0; pkw < nkw; pkw++)
{
if (islower (kw[pkw]))
{
kw[pkw] = kw[pkw] - 32;
}
}
string s = GetString();
int n = strlen(s);
int pkw = 0;
for (int p = 0; p < n; p++, pkw++)
{
if (isalpha (s[p]))
{
if (isupper (s[p]))
{
s[p] = ((s[p] - 'A') + (kw[pkw % nkw] - 'A')) % 26 + 'A';
printf("%c", s[p]);
}
if (islower (s[p]))
{
s[p] = ((s[p] - 'a') + (kw[pkw % nkw] - 'A')) % 26 + 'a';
printf("%c", s[p]);
}
}
else
{
printf("%c", s[p]);
}
}
printf("\n");
}