Why will this array not stop looping in c : <p>I am trying to display a <a href="http://pages.mtu.edu/~shene/NSF-4/Tutorial/VIG/Vig-Base.html" rel="nofollow noreferrer">Vigenere Square</a> but the for loop that creates it will not stop looping past the counter. You can find the loop under choice 1. Also if someone knows how to make the decrypt function to work.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

char encrypt(char, char);
char decrypt(char, char);

int main()
{
    int choice;
    printf("What would you like to do?\n\n");
    printf("1. Show board\n");
    printf("2. Encrypt\n");
    printf("3. Decrypt\n");
    printf("4. Exit\n");

    scanf("%i", &amp;choice);
    while(choice != 4){
        char key[9];
        char input[51];
        char decrypt[51];

        if (choice == 3 || choice == 2){
            printf("Give me a 9 character or less key in caps.\n");
            scanf("%s", &amp;key);
            printf("Give me a 51 character or less string in caps.\n");
            scanf("%s", &amp;input);
        }

        if (choice==1){
            int i, j;
            for(i=0;i&lt;=25;i++){
                for(j=0;j&lt;=25;j++){
                    printf("%c  ", encrypt((char) i, (char) j));
                }
                printf("\n");
            }

        } else if (choice == 2){
            int i;
            char text_crypt[51];

            for(i = 0; i &lt; strlen(input); i++){
                text_crypt[i] = encrypt(input[i], key[i % strlen(key)]);
            }
            printf("cyphertext is: %s\n", text_crypt);
        } else if (choice == 3){
            int i;
            char text_crypt[51];

            for(i = 0; i &lt; strlen(input); i++){
                text_crypt[i] = encrypt(input[i], key[i % strlen(key)]);
            }
            printf("cyphertext is: %s\n", text_crypt);

        }
    }
return 0;
}


char encrypt(char x, char y){
    return 65+((x+y)%26);
}

char decrypt(char x, char y){
    return 90-((x+y)%26);
}
</code></pre>

<p>I am trying to display a Vigenere Square but the for loop that creates it will not stop looping past the counter. You can find the loop under choice 1. Also if someone knows how to make the decrypt function to work.</p>
