Q:

Core Dumped and can't find the cause

I wrote a code whose function is to take values ​​into a binary search tree and then it checks if the left son and the father are equal.
The code works fine in Windows but I checked it on the Linux and it throws me a core Dumpted error. 
I test it with GDB to look for the error and it takes me to line 82(insert_into_arr function,also marked in code). I could not figure out the root of the error, I'd be happy if you looked at the issue.
input data: 8 8
output: 1
#include <iostream>
#include <iomanip>
#include <cstdlib>
//------------------------------------------------
using std::cin;
using std::cout;
using std::endl;
using std::cerr;
using std::nothrow;
//------------------------------------------------
struct Node
{
    int _data;
    struct Node *_left,
                *_right;
};
//------------------------------------------------
const int S = 100;
//------------------------------------------------
void build_bst(struct Node* &root, int arr[S]);
void insert_into_bst(struct Node* new_node, struct Node* &root);
void insert_into_arr(const int num, int arr[S]);
void arr_check_n_print(const int arr[S]);
void free_tree(struct Node* root);
void memory_failure();

//------------------------------------------------
int main()
{
    struct Node *root = NULL; //pointer to the root of the binary search tree
    int arr[S] = {0}; //assist arr for store values

    build_bst(root,arr); //call build bst function
    arr_check_n_print(arr); //call check array and print function
    free_tree(root); //call free memory

    std::cin.get(); std::cin.get();
    return EXIT_SUCCESS;
}
//------------------------------------------------
void build_bst(struct Node* &root, int arr[S])
{           //main build tree function receives root and arr by reference
    int num;

    cin >> num; //input into num
    arr[1] = num;  //first input will represent the root of the tree
    while (num != cin.eof() && num > 0)
    {
        //main input loop runs until eof & num > 0 (exercise request)
        struct Node *new_node = new (std::nothrow) struct Node; //potential
        if (new_node == NULL)
            memory_failure(); //cannot allocate memory

        new_node->_data = num; //update data like num
        new_node->_left = new_node->_right = NULL; //update to null for ending
        insert_into_bst(new_node, root);  //insert values into the bst by sort

        cin >> num; //new input
        if(num != cin.eof())
            insert_into_arr(num,arr); //insert into assist array
    }
}
//------------------------------------------------
void insert_into_bst(struct Node* new_node, struct Node* &root)
{
    //insert into bst function receives root by reference & new input by value
    if (root == NULL)
        root = new_node; //if it's the first element
    else if (root->_data >= new_node->_data) //sort checks & assume
        insert_into_bst(new_node, root->_left);
    else
        insert_into_bst(new_node, root->_right);

}
//------------------------------------------------
void insert_into_arr(const int num, int arr[S])
{
    //insert into assist array function receives 2 arguments
    int i = 1;
    while(true) //seems like no end loop but it has return in it
    {
        if(num <= arr[i] && arr[i*2] == 0) //algorithm check ** core dumpted lin
        {
            arr[i*2] = num; //algorithm assume
            return;
        }
        else if(num > arr[i] && arr[i*2+1] == 0) //algorithm check
        {
            arr[i*2+1] = num; //algorithm assume
            return;
        }
        else if(num <= arr[i]) //algorithm check for index increase
            i++;

        else
            i+=2;
    }
}
//------------------------------------------------
void free_tree(struct Node* root) //free memory function
{
    if (root != NULL)
    {
        free_tree(root->_left);
        free_tree(root->_right);
        delete root;
    }
}
//------------------------------------------------
void arr_check_n_print(const int arr[S]) //checking the equal values n printing
{
    int counter = 0;

    for(int i=1; i < S; i++) //runs until size
    {
        if(arr[i] == arr[i*2] && arr[i] != 0) //check if equal
            counter++;
    }
    cout << counter << endl; //output data
}
//------------------------------------------------
void memory_failure()
{
    cerr << "Cannot allocate memory\n";
    exit(EXIT_FAILURE);
}

A:

while (num != cin.eof() && num > 0)

When cin reaches end of file, this is equivalent to
    while (num != 1 && num > 0)
So unless your last number is 1 or negative, you'll go into an infinite loop adding that last number until the program crashes or the universe ends.
Specifically, cin.eof() returns a bool, so you are comparing int != bool. That causes the bool to be converted to 0 (false) or 1 (true).
I think what you want is while (!cin.eof() && num > 0) or better yet:
while ((cin >> num) && num > 0)

