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(¬e, sizeof(struct Persone), 500, fp); fclose(fp); add(BaseHead,BaseTail,note); printf("%s",BaseHead->data->fullname); return 0; }
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