This program I'm working on is a vigenere cypher in which a "plaintext" string is iterated through, each alphabetical character in which is adjusted by the alphabetically 0-indexed "key" string(argv[1]). When the end of the key string is reached it should loop back to the first character. I've been working on this for a little while but I've reached a brick wall with this error. The program reaches the initialization of "keyi"(which is meant to be the iteration of the "key" string) and then throws the error "Floating point exception (core dumped)." Now, I'm not sure how to read the "core" file that was dumped but I'm gonna guess, based on the error, that my definition is somehow creating a float that's causing an issue. I just can't understand how a float is being created at all though. The remainder of one int and another int should be an int, right?
I'm not sure what else I can try here, and I would really like to learn what my mistake here is and move on.
for(int i = 0; i < strlen(plaintext); i++)
{
if(isalpha(plaintext[i]))
{
printf("pass 0\n");
int keyi = (i + strlen(argv[1])) % (strlen(argv[1]));
printf("pass 1\n");
char cipherchar = plaintext[i] + argv[1][keyi];
//Adjust for 'alphabetical rotation'(when neccesary)
if((isupper(plaintext[i]) && cipherchar > 'Z') || (islower(plaintext[i]) && cipherchar > 'z'))
cipherchar -= 26;
printf("%c", cipherchar);