私は現在、情報の文字列を含む文字列を持つリンクリストに取り組んでいます。次のような構造体を使用しています。
struct symbolTable
{
string lexeme;
string kind;
string type;
int offSet;
symbolTable *nextSymbol;
symbolTable *nextTable;
};
挿入関数は次のようになります。
void MPParser::insertToSymbolTable(string identifier, string type, string kind)
{
tempOffset++;
symbolTable *tempNode;
tempNode = (symbolTable*)malloc(sizeof(symbolTable));
tempNode->kind = kind; //Run Time error Here..
tempNode->type = type;
tempNode->lexeme = identifier;
tempNode->offSet = tempOffset;
tempNode->nextTable = NULL;
tempNode->nextSymbol = root;
root = tempNode;
}
プログラムがコンパイルされ、実行してリンクされたリストに挿入しようとすると、次のエラーが発生します。
Unhandled exception at 0x5A6810D0 (msvcr110d.dll) in mpcompiler.exe: 0xC0000005: Access violation writing location 0xCDCDCDCD.
ポインターで文字列を別の文字列に割り当てる正しい方法は何ですか? または、私は何か完全に間違っていますか?どんな助けでも大歓迎です!
ありがとう!