Simple Caesar Cipher C++
Function by function review

findPosition()

This function is inefficient because it searches an alphabetized string trying to find the index of a lowercase letter.  It would be faster to not even use the string and just compute the position directly like this:

if (x &gt;= 'a' &amp;&amp; x &lt;= 'z')
    return x - 'a';


The other problem is what to return if the input character is not found.  Currently you return 26 and this causes the caller to print a null character (because chars[26] is the end of the string).  I think it would be preferable to return -1 and have the caller detect and deal with that.  So in total:

int findPosition(char x)
{
    if (x &gt;= 'a' &amp;&amp; x &lt;= 'z')
        return x - 'a';
    return -1;
}


nextChar()

This function works fine, but it gets called n times, where n is the number of times you are rotating.  You should be able to delete this function if you modified rotChar() appropriately.

rotChar()

Instead of calling nextChar() rotNum times, you should be able to use the modulo operator to compute the next character in one step:

// Rotate char desired amount
char rotChar(char x, int rotNum)
{
    int pos = findPosition(x);

    if (pos == -1)
        return x;
    return 'a' + ((pos + rotNum) % 26);
}


Notice that this also returns the character unmodified if it wasn't a lowercase character.  At this point, you might want to just eliminate findPosition() and just do everything in rotChar() like this:

// Rotate char desired amount
char rotChar(char x, int rotNum)
{
    if (x &gt;= 'a' &amp;&amp; x &lt;= 'z')
        return 'a' + (((x - 'a') + rotNum) % 26);
    return x;
}


Then you could easily extend this to handle uppercase letters as well:

// Rotate char desired amount
char rotChar(char x, int rotNum)
{
    if (x &gt;= 'a' &amp;&amp; x &lt;= 'z')
        return 'a' + (((x - 'a') + rotNum) % 26);
    if (x &gt;= 'A' &amp;&amp; x &lt;= 'Z')
        return 'A' + (((x - 'A') + rotNum) % 26);
    return x;
}