I have a database, I counted data from this database, I entered them in Persone (500 times) and now I need to put them in a queue, but I can't manage to put all 500 Persone structures in a queue, but only one, How to make a normal queue of structures?

struct Persone { char fullname[32]; int num; char date[10]; }; struct spis { struct spis *next; struct Persone *data; }; struct queue //очереди для digital sort { struct spis *head; struct spis *tail; }Q; void add(struct spis *&head,struct spis *&tail,struct Persone *array){ struct spis *p=(struct spis*)malloc(sizeof(struct spis)); p->data = array; p->next = NULL; if (head == NULL) { head = tail = p; head->next = NULL; } else { tail->next = p; tail = p; } } int main() { struct spis *p; struct spis *BaseHead; struct spis *BaseTail; BaseHead =(struct spis*)malloc(sizeof(struct spis)); BaseTail =(struct spis*)malloc(sizeof(struct spis)); BaseHead=NULL; BaseTail=NULL; struct Vertex *root = NULL; struct Persone note[4000]; FILE *fp; // Считываем данные из бд fp = fopen("basa.txt", "r"); fread(&note, sizeof(struct Persone), 500, fp); fclose(fp); add(BaseHead,BaseTail,note); printf("%s",BaseHead->data->fullname); return 0; } 
  • so you only call add once and add all note elements to the first node of the queue in the form data - Komdosh
  • one
    printf("%s",BaseHead->data->fullname); in fact, printf("%s",BaseHead->(*(data+0))->fullname); , to print the second one, printf("%s",BaseHead->(*(data+1))->fullname); - Komdosh
  • And your compiler is not C ++, that every time you repeat the word "struct"? One by one (FILE *) you can already understand what you are writing in C ++ ... - AR Hovsepyan
  • @Komdosh I can't do a cycle - gobeleeen
  • so add to the question how you tried to do with the cycle - Komdosh

0