C++ Problems modifying string with numbers : <p>I have made a simple encryption function,which encrypts everything except 0-9 numbers (ignoring the special characters).</p>

<p>Here is the code.</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

void encrypt(char s[])
{
    char *ptr;
    ptr=s;
    while(*ptr)
    {
            switch (*ptr)
        {
            case 'a':   *ptr='b';
                        break;
            case 'b':   *ptr='a';
                        break;
            case 'c':   *ptr='z';
                        break;
            case 'd':   *ptr='y';
                        break;
            case 'e':   *ptr='c';
                        break;
            case 'f':   *ptr='d';
                        break;
            case 'g':   *ptr='x';
                        break;
            case 'h':   *ptr='g';
                        break;
            case 'i':   *ptr='i';
                        break;
            case 'j':   *ptr='h';
                        break;
            case 'k':   *ptr='f';
                        break;
            case 'l':   *ptr='j';
                        break;
            case 'm':   *ptr='q';
                        break;
            case 'n':   *ptr='o';
                        break;
            case 'o':   *ptr='p';
                        break;
            case 'p':   *ptr='m';
                        break;
            case 'q':   *ptr='n';
                        break;
            case 'r':   *ptr='l';
                        break;
            case 's':   *ptr='k';
                        break;
            case 't':   *ptr='x';
                        break;
            case 'u':   *ptr='w';
                        break;
            case 'v':   *ptr='u';
                        break;
            case 'w':   *ptr='v';
                        break;
            case 'x':   *ptr='t';
                        break;
            case 'y':   *ptr='s';
                        break;
            case 'z':   *ptr='r';
                        break;
            case 1:   *ptr=5;
                        break;
            case 2:   *ptr=6;
                        break;
            case 3:   *ptr=0;
                        break;
            case 4:   *ptr=1;
                        break;
            case 5:   *ptr=2;
                        break;
            case 6:   *ptr=7;
                        break;
            case 7:   *ptr=4;
                        break;
            case 8:   *ptr=3;
                        break;
            case 9:   *ptr=8;
                        break;
            case 0:   *ptr=9;
                        break;
            default:    *ptr=*ptr;
                        break;
        }
        *ptr++;
    }
    *ptr='\0';
}

int main()
{
   char password[10];
   cout&lt;&lt;"Enter the password\n";
   cin&gt;&gt;password;
   encrypt(password);
   cout&lt;&lt;password&lt;&lt;endl;
   return 0;
}
</code></pre>

<p>Here is a sample output
sh-4.3$ main<br>
Enter the password<br>
thisisanex!!1234567<br>
xgikikboct!!1234567 </p>
