文字列をメモリに挿入中にエラーが発生しました。0xC0000005 アクセス違反エラー。配列サイズを変更しようとしたため、割り当てが正しくありませんでした。int の主要部分は、ファイルが終了するまで挿入関数に文字列の単語を送信するだけです。
#include<string>
#include<iostream>
#include <fstream>
using namespace std;
const unsigned int MAX = INT16_MAX;
string *words = new string[MAX];
int* instances = new int[MAX];
//int* alloc = new int[MAX];
int ucounts = 0;
static unsigned int FNVHash(string str) {
const unsigned int fnv_prime = 0x811C9DC5;
unsigned int hash = 0;
unsigned int i = 0;
unsigned int len = str.length();
for (i = 0; i < len; i++)
{
hash *= fnv_prime;
hash ^= (str[i]);
}
return hash;
}
void insert(string input) {
//check first, add if not present
if (words[FNVHash(input)] != input) { //<-Compiler shows error here.
words[FNVHash(input)] = input;
instances[FNVHash(input)]=1;
ucounts++;
}
else {
instances[FNVHash(input)]++;
}
}