im working on an encryption program and i need some help. so far it words fine except when i enter a space. when this happens it seems to end the loop and spit out the first word. any help would be great
#include <iostream>
#include <string>
using namespace std;
string rot13(string input)
{
int intVal = 0;
int length = input.size();
int charPosition = 0;
string finalText = "";
string character;
while(charPosition != (length + 1))
{
if(input[charPosition] >= 'A' && input[charPosition] <= 'M')
{
intVal = input[charPosition] + 13;
character = char(intVal);
finalText = finalText + character;
}
if(input[charPosition] >= 'a' && input[charPosition] <= 'm')
{
intVal = input[charPosition] + 13;
character = char(intVal);
finalText = finalText + character;
}
if(input[charPosition] >= 'N' && input[charPosition] <= 'Z')
{
intVal = input[charPosition] - 13;
character = char(intVal);
finalText = finalText + character;
}
if(input[charPosition] >= 'n' && input[charPosition] <= 'z')
{
intVal = input[charPosition] - 13;
character = char(intVal);
finalText = finalText + character;
}
if(input[charPosition] >= ' ' && input[charPosition] <= '@')
{
intVal = input[charPosition] + 0;
character = char(intVal);
finalText = finalText + character;
}
charPosition = charPosition + 1;
}
return finalText;
}