Hey
i need a had with using the queue remove function. Here is my code
void startDayClients(Queue ** clientQ) {
FILE *clients; //File pointer to client.txt
newClientNode *temp; //Temporary storage for clients
char name[30], address[40],one, final[20]; // variables for inputs
clients = fopen("client.txt", "r"); // remember - client.txt constant
if (clients == NULL) {
printf("Sorry cannot access file\n");
return;
}
//scanning in name and address of clients
while (!feof(clients)) {
fscanf(clients," %[^:]s", name);
fscanf(clients," %c", &one); //scan in : to avoid
fscanf(clients," %[^:]s", address);
fscanf(clients," %[^\n]s", final);
clientConstruct(name, address, &temp);
clientInsert(name, address, &temp);
printf("%s\n", temp->name);
printf("%s", temp->address);
if (!QueueFull((*clientQ))) { //insert into Queue if not full
QueueInsert((*clientQ), (&temp));
}
else {
printf("Sorry Queue is Full\n"); // warning if Queue is full
}
clientDelete(&temp);
}
fclose(clients); //close file
}
void listApplicants(Queue **clientQ) {
//list all applicants on the client queue
//change function - QUEUE output same for below listjobs
char exit[5], name[30], address[40];
Queue * newClientQ;
newClientNode *printNode;
printf("Applicant Name \t\tApplicant Address \n\n");
printNode = (newClientNode*)QueueRemove((*clientQ));
printf("%-30s\t\t%-40s\n", printNode->name, printNode->address);
printf("\n");
printf("Press Enter to Continue.");
//cant get it to scanf (or if do press enter nothing happens)
// if (strlen(exit) == 0) {
// return;
// }
}
the first function takes strings from the file and inserts them into the queue, then the listApplicant file the supose to remove each structure and print the name and address
here is the struct
struct newClientNode {
char *name; // character variable for clients name
char *address; // character variable for clients address
};
If anyone has an idea please give me a hand, I thinking it may have something to either do with inserting into the queue or how it is being removed
Thanks