Эй, я пытаюсь сохранить массив указателей (на структуры), но постоянно получаю сообщение об ошибке
ошибка: несовместимые типы при назначении типу "счетчик структуры" из типа "структура"counter * '
Но, насколько я знаю, код правильный.Есть идеи?
struct counter
{
long long counter; /* to store counter */
};
static struct counter* counters = NULL;
struct counter* makeNewCounter(void)
{
struct counter* newCounter = malloc(sizeof(struct counter));
newCounter->counter = 0;
return newCounter;
}
static void setUpCounters(void)
{
counters = malloc(ncounters * sizeof(struct counter*));
int i;
for (i = 0; i < ncounters; i++)
{
counters[i] = makeNewCounter(); //This is the line giving the error
}
}