I was reading details on Queues and Stacks and I have created many questions. How and why do people pass arguments to main. Where do they come from? Do multiple mains have the capability of talking to each other? Below is the code for a Queue that created the interest in this. I found it from the link also located below.
Link
Code:int main(int argc, char *argv[]) { Queue dataq; char cmd; QElement *data; int pos; do { cmd = getcommand(); switch (cmd) { case 'E': data = new QElement(getvalue()); dataq.Enqueue(data); cout << "Enqueued " << data->Getvalue() << endl; break; case 'D': data = dataq.Dequeue(); if (data == NULL) { cout << "Unable to dequeue from empty queue" << endl; } else { cout << "Dequeued " << data->Getvalue() << endl; } break; case 'P': pos = getvalue(); if (pos > dataq.Getsize()) { cout << "There are only " << dataq.Getsize(); cout << " elements currently in the queue" << endl; } else { data = dataq.PeekQ(pos); cout << "Value " << data->Getvalue(); cout << " is at position " << pos << endl; } break; case 'Q': break; default: cout << "Invalid command: " << cmd << endl; break; } } while (cmd != 'Q'); cout << "Bye!" << endl; return 0; }