Now I get MNOP on one line and two random numbers on the next :/
And if I make it to a string I dont know how to do, I mean how do I place a specific word on a specific place like a char? It's easy with a char to just do charname[i], but I don't know how to do so in a string :/ Yeah I am newb.
//create an index counter
unsignedint i = 0;
//ENCRYPT the message
//i < total size. if i == input.size()
//that would be the element which holds the '\0' character
//so we don't want to do anything with that element of the string
while( i < input.size() )
{
//if the current character is NOT a space.
//perform an action based on an upper
//or lower case character
if( input[ i ] != ' ' )
{
if( isupper( input[ i ] ) )
{
//if encryption called this function
if( encryption )
enUpper( input, i );
//else it's decryption
else
deUpper( input, i );
}
if( islower( input[ i ] ) )
{
if( encryption )
enLower( input, i );
else
deLower( input, i );
}
}
++i;
}
And one of the case functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void enUpper( std::string &input, int i )
{
//Ascii table. upper case Z = 90
constint upper = 90;
int decimal = input[ i ];
//add the shift ammount
decimal += cs;
//this performs a wrap-around
//if the shift goes z + 1
//take away 26 so that it is now 'a'
if( decimal > upper )
decimal -= 26;
//save the 'encrypted' letter
input[ i ] = decimal;
}