<p>What's the best way to get user input in a C program where the choices are of a limited number?</p>
<p>Say for example the choices are:</p>
<p>A) Print the list.
B) Add 99 to the end of the list.
C) Delete all duplicates.
5) Reset 5 times.</p>
<p>Entering &quot;A&quot; and then Enter is OK.
Or, just a single keystroke would work as well.</p>

I have used something simple like the following:
```
```
int intput()
{
    char input = 0;
    int ret_val = 0;

    read(0, &input, 1);

    switch(input) {
        case 'c':
            // Do c
            break;

        case 'p':
            // Do p
            break;

        case 'd':
            // Do d
            break;

        case 'q':
            quit = 1;
            break;

        case '?':
            PRINT(ENABLE, "c - connect\n");
            PRINT(ENABLE, "p - ping\n");
            PRINT(ENABLE, "d - disconnect\n");
            PRINT(ENABLE, "q - quit\n");
            PRINT(ENABLE, "? - this message\n");
            break;
    }

    return 0;
}
```
```