Q:

How do i use fgets and strtok to get multiple inputs?

I am having trouble using fgets() and strtok() to receive an input and splitting them up accordingly. 
Assuming I have a main menu that takes input 1-9, and every input leads to another function. I did that with just if statements and a break statement on every function. Now let say there is another command that takes a string, then a space, then 2 ints, how would I write it up in my menu?
That is any time in the menu, it can read just individual ints (1-9) and also read let say "start 5,9,forward" or "start ,4,2,backwards" in that menu. Do I write a logic that says if "start" is being input, go on go on, but I don't know how to make it so that it will then read for the space input after start and read the 2 ints and the last string.
Sorry if my question is a little confusing but I just want to know an example if receiving multiple inputs in a line and being able to manipulate those input variables. 

A:

Using fgets and strtok:
It is pretty much what @Cool Guy said.
...
fgets(buff, sizeof buff, stdin);
char a[25], d[25];
int b, c;
char *p = strtok(buff, ", "); //this will cut the input at an occurrence of `,` or `' '`, whatever happens first. At this point you would have the string "start" pointed by `p`.
strcpy(a, p);
p = strtok(NULL, ", ");
if(p) {
    b = atoi(p);
    if(b < 0 || b > 9) {
        //input error
    }
}
p = ...

The rest is analogous.
Using scanf solution:
You can read the input using scanf (yes, it is a powerful function).
scanf(" %N[^,' '] ,%1d%*[^,' '] ,%1d , %N[^\n]", a, &b, &c, d);

" %N[^,' ']" will read the input until the first , or ' ' (blank space) is reached. Also, replace N with the size of a - 1;
%1d%*[^,' '] will read an integer with one digit and discard the rest of the input until a , is found and store it in b;
%N[^\n] will read the rest of the line and store it in d. Replace N with the size of d - 1.
There are tons of tricks that you can use with scanf.
Please note that all whitespaces are important inside scanf's format in this case. Also, i am not treating the case where an user types a wrong input format, but it is possible.

