I'm trying to create an atomic array of a structure variable. But I cannot assign values to any array element.
struct snap {
int number;
int timestamp;
};
atomic<snap> *a_table;
void writer(int i, int n, int t1)
{
int v, pid;
int t1;
a_table = new atomic<snap>[n];
pid = i;
while (true)
{
v = rand() % 1000;
a_table[pid % n]->number = v;
this_thread::sleep_for(chrono::milliseconds(100 * t1));
}
}
The line a_table[pid % n]->number = v is showing an error (expression must have pointer type)