+ 1

How to input strings in a queue?

Let’s say that when running the code, the user decides to enter “Josh” who becomes the first person to enter the cash register line. Then, the user enters “Casie” and so on. Would the ideal form of declaring be char qput(), string qput() or something else?

16th Oct 2018, 1:14 AM
ManukaServer
ManukaServer - avatar
2 odpowiedzi
+ 6
If you are implementing queue using an array then simply take an array of strings. string data[20]; and if you are using a linked list then just modify the linked list node structure as struct node{ string data; node* next; };
7th Dec 2018, 9:06 AM
Himani
+ 2
I'd use string as it provides some protection from bugs. While knowledge of pointers is important, they should be avoided when ever possible.
16th Oct 2018, 11:52 PM
John Wells
John Wells - avatar