私は非常に単純なプログラムを作成しています。ちょっとしたチャット ボット AI のようなもので、プログラム用のコード、もちろん c++ があります。エラーは発生しませんが、実行すると、応答を停止したように、program.exe が動作を停止したことを示すウィンドウが表示されます。私のコードは次のとおりです。
#include<iostream>
#include<string.h>
#include<cmath>
#include<vector>
#include<ctime>
#include<conio.h>
#include<algorithm>
#include<cstdlib>
using namespace std;
struct strarray{
   char* array[];
};
struct keyword{
   string keywords;
   string responses[];       
};
keyword * dictionary = new keyword[2];
keyword defaultr;
keyword getMatch(string key);
string sconvert(string con);
void init();
string getResp(keyword key);
bool cont=true;
int main(int argc, char* argv[]){
   string input;
   while(cont){
            getline(cin,input);
            cout << getResp(getMatch(input));
            getch();
            getch();
   }
}
string sconvert(string con){
   con.erase(remove_if(con.begin(), con.end(), ::isspace), con.end());
   con.erase(remove_if(con.begin(), con.end(), ::ispunct), con.end());
   return con;
}
void init(){
   srand(time(NULL));
   dictionary[0].keywords="hello";
   dictionary[0].responses[0]="Hello, how have you been?";
   dictionary[0].responses[1]="Hello, have you missed me?";
   dictionary[0].responses[2]="Hey, how's it going?";
   defaultr.responses[0]="That's interesting, tell me more.";
   defaultr.responses[1]="Please, tell me more.";
}
keyword getMatch(string key){
    for(int i=0; i<sizeof(dictionary); i++){
            if(key==dictionary[i].keywords){return dictionary[i];}
    }
    return defaultr;
}
string getResp(keyword key){
   return key.responses[rand() % sizeof(key)];
}
実行すると正常に開きますが、起動時に何かを入力すると「動作が停止」します。何を変更する必要があるのか、なぜありがたいのか教えてください。
ポインターに問題がありますか?または何かrand?私は本当に混乱しており、実際に機能するようにこのプログラムを改善する方法についてアドバイスをいただければ幸いです。