C++ で試行を実装しようとしています。これが私が使用した構造です:
typedef struct tries{
int wordCount;
int prefixCount;
map<int,struct tries*> children;
}tries;
初期化メソッド:
void initialise(tries *vertex)
{
vertex = (tries*)malloc(sizeof(tries*));
vertex->wordCount = vertex->prefixCount = 0;
for(char ch='a';ch<='z';ch++)
vertex->children[ch]=NULL;
}
初期化メソッドにセグメンテーション違反がvertex->children[ch]=NULL;
あります。障害は次のとおりです。
Program received signal SIGSEGV, Segmentation fault.
0x000000000040139a in std::less<int>::operator() (this=0x604018,
__x=@0x21001: <error reading variable>, __y=@0x7fffffffddb8: 97)
at /usr/include/c++/4.6/bits/stl_function.h:236
236 { return __x < __y; }
なにが問題ですか?