error: initialization with "{...}" expected for aggregate object - c++

add ";" at the end of the struct.

struct test
{
    unsigned int test1;
    unsigned char test2[4096];
    unsigned int test3;
} foo ;

struct foobar
{
unsigned char data[4096];
} ;

You need to learn the array initialization method. It's NOT simply assigned as the single variable.

Some examples:

int arrayone[3] = {0}; // assign all items with 0

int arraytwo[3] = {1, 2, 3 }; // assign each item with 1, 2 and 3

int arraythree[3]; // assign arraythree with arraytwo
for (int i = 0; i < 3; ++i) {
    arraythree[i] = arraytwo[i];
}