This is the code I am using to change the string key into their respective shift values. For some reason as I have put a printf to test this, it outputs some weird strings of numbers.

int k[strlen(c)];
    for(int i = 0; i < strlen(c); i++)
            k[i] = c[i] - 'a';
            k[i] = c[i] - 'A';
        printf("%i", k[i]);

c is equal to argv[1]

  • What exactly does array k hold? You start by declaring it, then you have if (islower (k[i]) without populating k.
    – ronga
    Jun 15 '16 at 5:50

I think the mistake lies in the "if condition" in your for loop. The condition is islower(k[i]), which is seems to be wrong because the array is not initialised and must be containing some garbage values.

Instead, it should be replaced by islower(c[i]).(Afterall, the keyword is stored in c[] and not k[]).

Though, I am assuming that you verified the keyword to be valid.

You must log in to answer this question.

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