There's a small mistake in the elseif statement under if condition -
else if (isupper(s[i]) && islower(argv[1][j])) { printf("%c", ((((s[i] - 65) + (argv[1][j%kl] - 97)) % 26) + 65) ); }
(Just replace j with j%kl)
Edit : I found another mistake. Note that, while checking whether the character in your key is in uppercase or in lowercase, you are using argv[1][j]
. Instead you must use argv[1][j%kl]
. Otherwise it will go out of the range of valid indices as j increases.
Do hit the tick button beside the answer, if it works!