У меня есть структура для присвоения ему значений. Но моя программа разбивает его. Надеюсь, вы можете мне помочь.Как присвоить значения struct?
struct HashEntry{
std::string key; //the key of the entry
bool used; //the value of the entry
int value; //marks if the entry was used before
};
HashEntry *initHashList(int N){
HashEntry* hashList = new HashEntry[N];
for (int i = 0; i <= N; i++){
hashList[i].key = " ";
hashList[i].value = -1;
hashList[i].used = false;
}
for(int i = 0; i <N; i++){
cout<<hashList[i].value<<endl;
}
return hashList;
}
'i <= N' в вашем первом цикле должен быть' i
dfri
Измените 'i <= N' на' i