Insertion of a node in M-way search tree
This looks more like C than C++.
The only features of C++ I see used are #include &lt;iostream&gt;, using namespace std; and new.
Since this is flagged c++, I will review it as such, but if it is intended to use with C, a review for that language might give better insights.

Don't reinvent the wheel
The C++ standard library provides many features that would help. Need a sorting algorithm? Use std::sort. Need to find something in a container? Use std::find, std::lower_bound, std::upper_bound or some other algorithm that suits your needs!
Naming
Many variables have very short and cryptic names. This makes the code hard to read.
Example: What does mWay::k stand for?
Issues

Elements of &lt;iostream&gt; aren't used anywhere.

using namespace std; is discouraged, especially in headers. If someone else includes that header, it might cause ambiguities in their code!


Design
C++ has classes. Why not use them to define the tree, instead of a loose set of free standing functions?
For example, a rough outline could look like this:
#include &lt;array&gt;
#include &lt;memory&gt;
#include &lt;algorithm&gt;

template&lt;typename ValueType, size_t Arity&gt;
class nary_search_tree {
    static_assert(Arity &gt;= 2u, &quot;Tree needs an arity greater than or equal to 2!&quot;);

    class node {
        size_t size = 0;
        std::array&lt;ValueType, Arity-1&gt; values;
        std::array&lt;std::unique_ptr&lt;node&gt;, Arity&gt; children;

        void insert_in_order(ValueType value) {
            auto insert_index = find_child_index(value);
            
            if(insert_index == size) {
                values[insert_index] = value;
                ++size;
                return;
            }
            
            std::copy_backwards(&amp;values[insert_index], &amp;values[size-1], &amp;values[size]);
            values[insert_index] = value;
            ++size;
        }

        void find_child_index(ValueType value) const {
            for(auto i = 0u; i &lt; size; ++i) {
                if(values[i] &gt; value) return i;
            }
            
            return size;
        }

    public:
        void insert(ValueType value) {
            if(index &lt; values.size()) {
                insert_in_order(value);
                return;
            }

            auto index = find_child_index(value);
            if(!children[index]) {
                children[index] = std::make_unique&lt;node&gt;();
            }

            children[index]-&gt;insert(value);
        }
    };

    std::unique_ptr&lt;node&gt; root = nullptr;

public:
    void insert(ValueType value) {
        if(!root) root = std::make_unique&lt;node&gt;();
        
        root-&gt;insert(value);
    }
};

Makes reasoning much easier, doesn't it? And as a bonus, it's much more generic, too!
Note: This code requires C++11 or later to work.

Of course, this is just the beginning... This code could be improved, e.g. by using const ValueType&amp; to prevent copies and by using overloads for ValueType&amp;&amp; to support movable types. Also, other search tree functionality is missing, like looking up an element