Project Euler #22 - Name scores
The code is generally pretty clean, however, the major sticking point is that everything here is just shoved into main. Just breaking this up with a few functions that do one thing would be a good start:

std::vector&lt;std::string&gt; read_file(const std::string&amp; path)
{
    std::ifstream file(path);

    if (!file.is_open())
    {
        std::cerr &lt;&lt; "Unable to open file" &lt;&lt; "\n";
        std::exit(-1);
    }

    std::vector&lt;string&gt; words;
    std::string token;

    while (std::getline(file, token, ','))
    {
        words.push_back(token);
    }

    return words;
}


I've also put back all the std:: namespace qualifier. Using namespace std is something that is ok for very short programs like this, but is something you shouldn't get into the habit of doing.

How about a function to sum the values in a word?

int sum_word(const std::string&amp; word)
{
    constexpr static int ascii_to_integer = 64;
    int total = 0;
    for(auto c : word) {
        total += (c - ascii_to_integer);
    }
    return total;
}


In fact, if you want to be fancy, this can be even shorter:

int sum_word(const std::string&amp; word)
{
    constexpr static int ascii_to_integer = 64;
    return std::accumulate(word.begin(), word.end(), 0, [](int i) { return i - ascii_to_integer; });
}


Finally, we can have a function to encompass the outer loop (processing each word in the vector):

int total_word_position(const std::vector&lt;std::string&gt;&amp; v)
{
    int counter = 1;
    int total = 0;

    for(const std::string&amp; s : v) {
        // Exclude " "
        std::string word(s.begin() + 1, s.end() - 1);
        total += (sum_word(word) * counter);
        ++counter;
    }
    return total;
}


Your main method would then become:

int main()
{
    std::vector&lt;std::string&gt; all_words = read_file("E:\\names.txt");
    std::sort(all_words.begin(), all_words.end());
    int grand_total = total_word_position(all_words);
}


This has a number of benefits:


Variable scope is minimized to a single smaller function, instead of a large main function.
It's generally easier to read and debug, as there is less to keep in your head.
It separates parts of the program that do very different things (reading a file vs sorting vs summing numbers).