I am learning programming and I made a code to avarage as much numbers as I want. The code runs perfectly in Visual Studio, but when I try to run it with the exe file it dies after I type in "end". I use "end" to break the loop (23rd line).
#include <iostream>
#include <string>
using namespace std;
int main()
{
string n = "";
double a = 0;
double counter = 0;
string list = "0123456789.";
int b = 0;
char betu = '\0';
int num = 0;
double value = 0;
while (true) {
    betu = '\0';
    n = "";
    a = 0;
    b = 0;
    cout << "Send in a number:" << endl;
    cin >> n;
    b = n.length();
    if (n == "end") {
        break;
    }
    for (int i = 0; i < b; i++) {
        if (list.find(n[i]) == string::npos) {
            cout << "The number is not correct.";
            exit(EXIT_FAILURE);
        }
    }
    a = stod(n);
    counter += a;
    num++;
}
if (num == 0) {
    cout << "not enough numbers to count with." << endl;
}
else {
    value = counter / num;
    cout << "The avarage of your results is: " << endl;
    cout << value << endl;
}
return 0;
}
I want "end" to quit the loop and continue the program after the loop.
 
    