Converting space character in string to integer

Hi all. I am currently trying to write a program that implements the Ceasar cypher, which shifts all the letters in a message a certain number of letters forward. The way I am doing this is turning each letter into its ASCII number via static_cast-ing, doing a numerical formula to apply the shift, and then changing the new numbers back into letters to get the encrypted letter.

This worked fine for letters, but the problem is, I would like it to leave spaces (' ') alone, encrypting only letters themselves and leaving the spaces in the same spots. To do this, I say (where plaintext[i] is the original letter and cyphertext[i] is the new letter):

if (plaintext[i] == ' ')

cyphertext[i] = ' ';

else

//numerical formula for encrypting letters

However, it is not working at all. It ends up converting spaces into letters or symbols. Is there some wierd issue that I am not aware of forbidding comparisons with blank space? Any suggestions for how to fix this would be greatly appreciated. Thanks.