0

Been able to write code to encrypt text (vigenere encryption). But one question intrigues me.

If I use

        if (!isalpha(s[i]))

encryption does not produce expected output for, for example, "world, say hello!" as it messes up the key index (I suppose!) (check50).

but if I use

        if ((s[i] != ' ') || (!isalpha(s[i])))

(may be I should try (ispunct(s[i]) and (isspace(s[i]): does work, just checked).

The question still is something I would like to know:

Does isalpha() treat 'space' character as a part of alphabet?

Being a novice at programming, I hope someone can clarify this.

thanks

4
  • There's not enough code there to give an intelligent reply. Can you edit your question to be more specific and add the related section of code?
    – Cliff B
    Sep 12 '16 at 5:39
  • The point here has less to do with the code itself but is about the scope of the function isalpha() {or !isalpha}. Sep 12 '16 at 21:35
  • 1
    It is more likely that the problem you are experiencing is not to do with isalpha() but the way that you have written your code. The "world, say hello!" test in check50 is designed specifically to look for this issue. Also, it's a very common error for this pset. I would wager that "say" is incorrectly encoded. In answer to your question though, isalpha() only returns true for actual letters, not spaces, numbers, punctuation, or anything else.
    – Cliff B
    Sep 12 '16 at 21:49
  • Thanks. There must have been a problem with coding; isalpha() does exclude spaces... Sep 13 '16 at 13:49
0

A Zombie Question is born. @AnilKhosla, please post your last comment as an answer and accept it by clicking on the green check mark; otherwise, it will remain marked as unanswered and haunt the forum forever.

0

Thanks. There must have been a problem with coding; isalpha() does exclude spaces...

You must log in to answer this question.

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