+ 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?
2 Answers
+ 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;
};
+ 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.