我正在尝试使用双指针**通过另一个结构'Dict'访问结构'Word'的成员,但在Visual Studio 2010中出现'访问冲突'错误。我也在stackoverflow上检查了链接“访问结构的双指针”,但它也没有解决问题。有人可以帮我识别代码中的错误吗?我在这里内联代码:
============================================
#include <iostream>
#include <stdlib.h>
#include <time.h>
//#include "dict.h"
using namespace std;
enum WordType{All, Animal, Fruit, Name};
struct Word{
WordType type;
char word[20];
};
struct Dict{
int size;
int capacity;
Word **wordArray;
};
int main() {
Dict *dic = new Dict;;
dic->size=0;
dic->capacity=0;
strcpy((dic->wordArray[0])->word,"hi");
cout<< (dic->wordArray[0])->word;
system("pause");
return 0;
}
==================================================== ======