Q:

Why does my code only work properly one time?

Good day everyone,
I have to make a program that is suppose to do the following:
1) Asks the user to input a string.
2) Asks the user to input an integer (lets call it 'n').
3) Replaces each character in the string by a character ahead by 'n' in the alphabet.
4) Prints the new string to the console.
For example:
if string = abc AND integer = 1 the result will be bcd.
if string = Hello AND integer = 4 the result will be Lipps.
if string = Welcome-2-C++ AND integer = 13 the result will be Jrypbzr-2-P++ (special characters like $,+,/ remain unchanged).
I've written some code that works properly:
(code removed)

Except that it only works one time. This is what the console looks like:
Please insert a string to convert: 
abc
Please enter the modification integer: 
2
The resulting string is: cde
Please insert a string to convert: 
abc
Please enter the modification integer: 
2
The resulting string is: 
Please insert a string to convert: 

As you can see, the second time the program runs, there's no result.
Why does my program only work properly the first time it runs?
P.S. I've done some of my own debugging and it seems that the "for loop" is skipped the second time the program runs. (?)
EDIT: I think this might have something to do with memory allocation?

A:

You aren't initializing your loop variable:
for (int i; i < input_string.length(); i++) {

Should be int i = 0;. 

Also, your ConvertString can also be massively simplified:
string ConvertString(string input_string, int mod_int) {
    for (char& c : input_string) {
        if (std::isupper(c)) {
            c = 'A' + (c - 'A' + mod_int) % 26;
        }
        else if (std::islower(c)) {
            c = 'a' + (c - 'a' + mod_int) % 26;
        }
    }
    return input_string;
}

