0

I am stuck while working on pset2 vigenere. I am trying to create two variables (i and l) in the same for loop however I do not know what is the correct format to do that. If I create two variables separately, the second variable will always go under the first variable's loop and creates a result that I do not want.

my code is as follow, please let me know what is the correct way to write this. Thank you!

enter image description here

1 Answer 1

0

Depending on what you want to do, this is one possibility:

for(int i=0, l=0, n=strlen(s); l < strlen(k) && i < n; i++, l++)

But have you thought about what will happen? both i and l (I assume they are the index vars for the plaintext and the key) will be incremented on every pass through the loop.

What happens when a non-alpha is being processed?

What happens when the loop gets to the end of the key before the end of the plaintext? Or the other way around?

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • Thank you for your hints! I will figure out it more!
    – Issa
    Commented Jul 18, 2018 at 1:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .