I am trying to get my code to skip spaces, I can't work out why it is not working

// Converts plain text to cipher text
        for (int l = 0, o = strlen(s); l < o; l++)
        {
            // Obtains value of index for key for this letter
            m = (l % t); 

            // Checks if plaintext letter is alphabetical character 
            if (isalpha(s[l]) == 0)
            {
                char c = s[l];
                printf("%c", c);
            }
            else
            {
                if (islower(s[l]))
                {
                    char c = ((s[l] + shift(key[m]) - 97) % 26 + 97);
                    printf("%c", c);
                    m++;
                }
                else if (isupper(s[l]))
                {
                    char c = (s[l] + shift(key[m]) - 65) % 26 + 65; 
                    printf("%c", c);
                    m++;
                }
                ````

Alright, you need to either run this under gdb and put break points at the lines that aren’t working, or print out the variables with printf to see if they’re changing right. I suspect the shift() lines are causing the problems.

A free service run by Zed A. Shaw for learncodethehardway.org.