Trouble assigning/declaring a __64int (long long int) array

281 views Asked by At

I'm trying to run this code:

#include <iostream>
#include <time.h>
#include <stdlib.h>
#include<stdint.h>
#include "BSTTemplate.h"
#include "functions.h"

using namespace std;

int main()
{
    const __int64 SIZE = 1000000LL;
    __int64 randNum;
    binarySearchTree<__int64> bst1;
    __int64 numArray[SIZE];


    //I have more code after but the problem is occurring at the above code.

    return 0;
}

I'm not getting any syntax errors because it compiles but it crashes as soon it runs. I commented all the code that came after these declarations and it crashed in the same way. I tried using Step Into to debug it but it won't go past the first bracket '{' and instead it opens up some assembly code and an error that says the stack overflowed. Any help as to what I'm doing wrong? This is my first time using data types greater than ints. I tried looking up solutions but they either didn't help or I didn't understand them. I'm also using a 64 bit computer.

And I know that 1 million can fit into a long int but I'll be using numbers in the billions so I wanted to just make everything a long long int (or a __64int).

At EdMaster's request here is the code for BSTTemplate.h:

template <class type>
class binarySearchTree
{
private:
    template<class type>
    struct nodeType
    {
        type info;
        nodeType<type> * lLink;
        nodeType<type> * rLink;
    };

    nodeType<type> * root;

public:
    binarySearchTree();
    int height(nodeType<type> *p);
    bool search(const type &searchItem) const;
    void insert(const type &newData);
    void deleteNode(const type &deleteItem);
    void deleteFromTree(nodeType<type> * &p);

    int numDups;
};

Not sure how this would be the cause of the problem. None of the method definitions are allocating memory, except for the insert method one at a time.

1

There are 1 answers

4
πάντα ῥεῖ On BEST ANSWER

"... and an error that says the stack overflowed ..."

const __int64 SIZE = 1000000LL;
// ...
__int64 numArray[SIZE];

is likely to require more stack memory than is available as configured for your process (you would need 7812 KB at least: (1000000 * 64 / 8) / 1024 ). Try using a dynamic memory allocation instead:

std::vector<__int64> numArray(SIZE);