Everyone help me fix this! I can not fix it! thank you so much

Write your question here.
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
#include<math.h>


//NV structure define
struct NV
{
char hoten[32];
int NS;
float HSL;
float LuongCB;
};
// Node structure define
struct Node
{
NV item;
struct Node*Next;
} ;
// Queue structure define
struct Queue
{
Node *Head;
Node *Tail;
};
Queue q;
// empty Queue
void QueueInitialize(Queue *q)
{
q->Head=q->Tail=NULL;
return;

}
// check empty Queue
int QueueEmpty(Queue q)
{
return (q.Head==NULL);
}
Node *getNode(NV x)
{
Node *p;
p=new Node();
if(p==NULL)
{
printf("\n Error!");
exit(0);
}
p->item=x;
p->Next=NULL;
return p;
}

// nhap cho mot phan tu of Queue
void nhap(NV &x)
{

fflush(stdin);
printf("\n Name: ");
gets(x.hoten);
fflush(stdin);
printf("\n"Year of Birth: ");
scanf("%d",&x.NS);
printf("\n coefficients salary: ");
scanf("%f",&x.HSL);
printf("\n basic salary: ");
scanf("%f",&x.LuongCB);

}
void hien(NV x)
{
printf("\n %20s",x.hoten);
printf("\n %7d",x.NS);
printf("\n %3.2f",x.HSL);
printf("\n%3.2f",x.LuongCB);
}
// insert Queue
void Put(Queue *q,Node *p)
{
NV x;

p=(Node*)malloc(sizeof(Node));
p->item=x;
p->Next=NULL;
q->Tail->Next=p;
q->Tail=q->Tail->Next;
if(q->Head==NULL)
q->Head=q->Tail;
return ;
}

// dellete Queue
void Get(Queue *q)

{
Node *p;
if(QueueEmpty(*q))
{
printf("\n Queue empty!");
return 0;
}
else
{
p=q->Head;
q->Head=q->Head->Next;
return p->item;
}
}


void nhapDS(Queue &q)
{
int n,i;
Node *p;
NV x;
printf("\n number the staff: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
nhap(x);
p=getNode(x);
Get(&q);

}
}
//hien Queue
void hienDS(Queue q)
{
Node *p;
for(p=q.Head;p!=NULL;p=p->Next)
hien(p->item);
}
void nhapfile(Queue q)
{
DeleteFile("quanlysach.dat");
FILE*f;
f=fopen("quanlysach.dat","wb");
Node*p=q.Head;
while(p!=NULL)
{
Put(&q,p);
fwrite(&p->item,sizeof(p->item),1,f);
p=p->Next;
}
fclose(f);
}

void docfile(Queue &q)
{
QueueInitialize(&q);
NV x;
FILE*f;
f=fopen("quanlysach.dat","r+");
fread(&x,sizeof(x),1,f);
while(!feof(f))
{
Get(&q);
fread(&x,sizeof(x),1,f);
}
fclose(f);
}


int main()
{

Node *p;
FILE *f;
QueueInitialize(&q);
docfile(q);
printf("\n DSNV da nhap:");
hienDS(q);
getch();
return 0;
}
Last edited on
See where you wrote, "Write your question here." Please do so. What problem are you having? I'm not going to search through your code not even knowing what the problem is, especially without code tags.
Topic archived. No new replies allowed.