Ошибка «3 [main] a 8724 cygwin_exception :: open_stackdumpfile: дамп трассировки стека в a.exe.stackdump» - PullRequest
0 голосов
/ 05 января 2019

Я пытаюсь создать хеш-карту для хранения символов из строки. Кажется, я не могу найти проблему, вызывающую ошибку «3 [main] a 8724 cygwin_exception :: open_stackdumpfile: дамп трассировки стека в a.exe.stackdump». Я считаю, что это где-то в hasher.cpp и имеет какое-то отношение к присваиванию значений, но за этим я полностью озадачен. Любая помощь будет высоко ценится!

Я пытался закомментировать некоторые части main.cpp. Когда я просто создаю экземпляр хеша с именем map, код работает. Когда я пытаюсь инициализировать или распечатать, выдается ошибка.

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);
};

Я считаю, что все заголовки / структуры данных являются правильными (определен узел и хэш-карта, представляющая собой массив узлов, каждый узел имеет следующий указатель).

Заранее спасибо за любую помощь!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...