Error "3 [main] a 8724 cygwin_exception::open_stackdumpfile: Dumping stack trace to a.exe.stackdump"

1k Views Asked by At

I am trying to create a hash map to store characters from a string. I cannot seem to find the issue causing the error "3 [main] a 8724 cygwin_exception::open_stackdumpfile: Dumping stack trace to a.exe.stackdump". I believe it is somewhere in the hasher.cpp and has something to do with assigning values, but beyond that I am completely stumped. Any help would be much appreciated!

I've tried commenting out certain portions of the main.cpp. When I simply instantiate the hasher called "map", the code works. When I attempt to initialize or print, the error is thrown.

main.cpp:

#include <iostream>
#include <stdio.h>
#include <string.h>
#include "hasher.h"
using namespace std;

int main(void){

  hasher *map = new hasher;
  map -> initialize(map);
  map -> printHash(map);

  return 0;
}

hasher.cpp:

  #include "hasher.h"
  #include <iostream>
  using namespace std;

  hasher::hasher(){

  }

  void hasher::initialize(hasher *h){ //initialize all charachters to spaces
    for(int i = 0; i < hasherSize; i++){
      h -> arr[i] -> C = ' ';
    }
  }

  void hasher::insert(hasher *h, char ins){
    int addr;
    int value = (int)ins; //value will be the ascii value of the char

    addr = value / 7; //map the current character to the ascii value mod 7

    node *curr = h -> arr[addr];
    while(curr -> next != nullptr){
      curr++;
    }
    curr -> next -> C = ins;
  }

  void hasher::del(hasher *h, char delChar){

  }

  bool hasher::inString(hasher *h, char se){

  }

  void hasher::printHash(hasher *h){
    for(int i = 0; i < hasherSize; i++){
      cout << h -> arr[i] -> C;
      node *curr = h -> arr[i];
      while(curr -> next != nullptr){
        curr++;
        cout << ", " << curr -> C;
      }
      cout << endl;
    }
  }

hasher.h:

#include "node.h"
#define hasherSize 40
using namespace std;

class hasher{
  public:
    node* arr[hasherSize];

    hasher();
    void initialize(hasher *H);
    void insert(hasher *H, char ins);
    void del(hasher *H, char del);
    bool inString(hasher *H, char searchChar);
    void printHash(hasher *H);
};

I believe all headers/data structures are correct (defined a node and a hash map that is an array of nodes, each node has a next pointer).

Thanks in advance for any help!

0

There are 0 best solutions below