# pset2 vigenere.c not looping over the plaintext input

I thought I had coded a loop for the plaintext input characters to be converted by the cipher, but my output is only the first character.
I don't know where I have gone wrong, any pointers?

Also, I think I may have coded the keyword key into numbers twice but I can't check as I can't get the whole output. Any help?

Here is my code:

``````int main(int argc, string argv[])
{
//just the program and the keyword
if (argc !=2)
{
printf("You have not entered the encryption key correctly.\n");
return 1;
}
else
{
//check each letter in keyword is alphabetic characters
for(int i = 0; i < strlen(argv); i++)
{
if (!isalpha(argv[i]))
{
printf("Only alphabetic characters can be used.");
return 1;
}
}

{   //convert argv1 to numbers
string keyword = argv;
int keylength = strlen(keyword);
int key[keylength];

for(int l = 0; l < keylength; l++)
{
key[l]=toupper(keyword[l]) - 65;
}

//get the message to be ciphered
{
string text = GetString();

//change each letter for the key
for(int j = 0; j < strlen(text); j++)
{
//iterate through the plaintext if alpha character
if(isalpha(text[j]))
{
int k = 0;

//iterte through
for(int k =0; k < keylength; k++)
if(islower(text[j]))
{
int a = (((text[j] - 97 + key[k]) % 26) + 97);
printf("%c", a);
}

if(isupper(text[j]))
{
int b = (((text[j] - 65 + key[k]) % 26) + 65);
printf("%c", b);
}
}

else
{
//if not upper or lower case letter then just print
printf("%c", text[j]);
}

printf("\n");
return 0;
}
}
}
}
}
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.60119945,"math_prob":0.97782385,"size":1443,"snap":"2021-21-2021-25","text_gpt3_token_len":418,"char_repetition_ratio":0.116052814,"word_repetition_ratio":0.007874016,"special_character_ratio":0.35620236,"punctuation_ratio":0.14089347,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9834895,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-13T06:11:43Z\",\"WARC-Record-ID\":\"<urn:uuid:93645b4b-a33e-40bc-bc9c-eb17ddee9099>\",\"Content-Length\":\"136069\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:171861c4-0c97-474c-87fd-3af7725bda6e>\",\"WARC-Concurrent-To\":\"<urn:uuid:ed26ad99-7972-4e3b-84f1-8a44df5ba0b5>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://cs50.stackexchange.com/questions/15197/pset2-vigenere-c-not-looping-over-the-plaintext-input\",\"WARC-Payload-Digest\":\"sha1:PF2A7MAOQ54TTOGT47YFUYJKLJQIYTEP\",\"WARC-Block-Digest\":\"sha1:YX7QVLO64YT74TI4LAM6XGYILEP4RCVT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243991537.32_warc_CC-MAIN-20210513045934-20210513075934-00109.warc.gz\"}"}