Most common words in a text file
Declare variables as late as possible. int i, k, j, n, l, tabl; What do these variables do? It is quite difficult to figure that out. If you declare and initialize them when needed it would be clear.
Keep variables as local as possible. A loop such as for(i = 0; i &lt; str.length(); i++) makes me think the result of i is required later which it is not (I think). Prefer for (int i = 0; i &lt; str.length(); i++).
People do not like using namespace std;.
tab[10000] and char c = 179; have magic numbers. Why 10000 and 179? Since you know how to use vector it is hard to guess why you thought having 10000 stings twice is a good idea.
This seems to be a major performance problem (you are supposed to profile because obvious performance problems can get fixed by the optimizer and the line between what the optimizer thinks is obvious and which is not is very hard to predict):

while(getline(in, str2)){
    str += str2;
    str += ' ';
}


This produces a string to hold a single line. Then it adds a line, but it is out of memory, so it allocates new memory for 2 lines, copies 2 lines and throws the memory for 1 string away. Then it allocates memory for 3 lines, copies 3 lines and throws 2 lines of memory away. When you start allocating memory for 100 lines, copy 100 lines and throw 99 lines worth of memory away things get slow. I would suggest counting words one line at a time instead of reading the whole file at once.
Use functions. Some people do not allow more than 10 lines per function, otherwise it must be re-factored into multiple functions. 10 lines are a bit strict, but you should separate concerns. One function to get the input, one function to do the word counting, one function to do the output. Maybe some functions will be too complicated and need to be split up further. The point is that if you need to change a part of the program you see from the function names where to change what.
I looked at your loops and indexes and I don't even want to try to understand what is going on. You can replace almost all of that with a map&lt;string, int&gt;.


This is what I came up with (it is 4:35 am here). My code kind of deserves a review of its own because it makes me look a bit hypocritical.

    #include &lt;iostream&gt;
    #include &lt;string&gt;
    #include &lt;map&gt;
    #include &lt;algorithm&gt;
    #include &lt;cctype&gt;
    #include &lt;vector&gt;
    #include &lt;sstream&gt;
    #include &lt;fstream&gt;
    #include &lt;iomanip&gt;

    void removeNonAlphabeticalCharacters(std::string &amp;s){
        s.erase(std::remove_if(std::begin(s), std::end(s), [](char c){ return !isalpha(c); }), std::end(s));
    }

    template&lt;class Iterator&gt;
    //constraint: Iterator::value_type == std::pair&lt;std::string, int&gt;
    void displayRanking(Iterator begin, Iterator end, int wordcount){
        int index = 1;
        while (begin != end){
            std::cout &lt;&lt; '|' &lt;&lt; index &lt;&lt; ".\t|" &lt;&lt;
                begin-&gt;first &lt;&lt; "\t|" &lt;&lt; begin-&gt;second &lt;&lt; "\t|" &lt;&lt; 
                std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; begin-&gt;second * 100.f / wordcount &lt;&lt; "%\n";
            ++begin;
            index++;
        }
    }

    int main(){
        std::map&lt;std::string, int&gt; wordcounter;
        std::string input;
        int totalwords = 0;
        std::ifstream in("file.txt");
        while (in &gt;&gt; input){
            removeNonAlphabeticalCharacters(input);
            wordcounter[input]++;
            totalwords++;
        }
        if (totalwords == 0){
            std::cout &lt;&lt; "failed reading words from file\n";
            return 0;
        }

        //how many words to display in the ranking
        const int top = std::min((size_t)20, wordcounter.size());
        //copy wordcounter to vector for sorting
        std::vector&lt;std::pair&lt;std::string, int&gt;&gt; toplist;
        toplist.reserve(wordcounter.size());
        std::copy(std::begin(wordcounter), std::end(wordcounter), std::back_inserter(toplist));
        auto comparator = [](const std::pair&lt;std::string, int&gt; &amp;lhs, const std::pair&lt;std::string, int&gt; &amp;rhs){return lhs.second &gt; rhs.second; };
        std::partial_sort(std::begin(toplist), std::begin(toplist) + top, std::end(toplist), comparator);

        displayRanking(std::begin(toplist), std::begin(toplist) + top, totalwords);
    }


There are many ways to improve readability and performance still, but let me know how long my code takes with your input file.