====== Массив из Struct указателей ====== #include #include using namespace std; struct Task { void* next; bool active; char* title; }; Task* first; Task* addTask(const char* title) { Task* t = first; while (t != NULL && t->active != false && t->next != NULL) t = (Task*) t->next; if (t->active == true) { t->next = (void*) malloc(sizeof(Task)); t = (Task*) t->next; } free(t->title); t->active = true; t->title = (char*) malloc(strlen(title)+sizeof(char)); memcpy(t->title, title, strlen(title)); return t; } void destroy_tasks(Task* first) { Task* next = (Task*) first->next; free(first->title); free(first); first = NULL; if (next != NULL) { destroy_tasks(next); } } int main() { first = (Task*) malloc(sizeof(Task)); first->next = NULL; addTask("Hello world"); addTask("Hello univerce"); addTask("Hello Enigma"); Task* t = first; while (t != NULL) { if (t->active) { cout << t->title << endl; } t = (Task*) t->next; } destroy_tasks(first); cout << "end" << endl; return 0; }