cin has muliple inputs

For a program I am required to use a cin that accepts 4 variables. The first describes a function such as add(), remove(), print(), or quit(). The problem is that to use add() I need to input all 4 variables but for remove(), only 2 variable input is needed.

I want the input to be "add 9 James Bond"
or be "remove 341"

Can anyone help? Here is my current code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
int command(string command, int Id, string first, string last)
{

while (command != "quit")
{

cout << "customers> ";
cin >> command >> Id >> first >> last;
        if (command == "add")
        {
        add(Id,first,last);
        cout << "added" << endl;
        }
        else if (command == "remove")
        {
        remove(Id);
        cout << "remove" << endl;
        }
        else if (command == "print")
        {
        cout << "print" << endl;
        }
        else if (command == "quit")
        {
        return 0;
        }
        else if (command != "add" || command != "remove" || command != "print" |$
        {
        cout << "Error Message" << endl;
        continue;
        }

}

}
Last edited on
If you don't need to read them, then don't read them.
Topic archived. No new replies allowed.