hej. poniżej struktury, i funkcja push użyta do konstruowania kolejki:
struct record{
int year,month,day,dvds;
float nosnik,przychod,zarobek;
}wiersz;
struct base {
struct record node;
struct base *prev,*next;
}db;
struct base_holder{
struct base *head,*tail;
}holder;
(...)
void push(struct record wiersz){
struct base *newptr;
newptr=(struct base*)malloc(sizeof(struct base));
newptr->node=wiersz;
newptr->next=NULL;
newptr->prev=NULL;
if (holder.head==NULL && holder.tail==NULL){
holder.head=newptr;
holder.tail=newptr;
}
if (holder.head!=NULL && holder.tail!=NULL){
newptr->next=holder.head;
holder.head->prev=newptr;
holder.head=newptr;
}
}
i funkcja wyświetlająca zawartość kolejki:
void queue_print(){
struct base *temp;
temp=(struct base*)malloc(sizeof(struct base));
temp=holder.head;
while (temp->next!=NULL)
//int i;
//for(i=1;i<200;i++)
{
wiersz=temp->node;
printf("%u-%-0.2u-%-0.2u%10u%10f%10f\n",wiersz.year,wiersz.month,wiersz.day,wiersz.dvds,wiersz.nosnik,wiersz.przychod,wiersz.zarobek);
temp=temp->next;
}
}
ostatnia funkcja, a właściwie parametr pętli while jest niepoprawny - pętla nieskończona.
Jeżeli while zamienimy na FOR (wykomentowany), zawartość pętli wykonuje sie poprawnie.
Co zmienić w while, żeby działało?