I have a program that reads the input from keyboard using readline()
. its like a simple shell that reads the input string and acts on the commands being passed.
the strtok() function looks simple but how do i implement it. Assuming the string from input i get is called "reply".
and i'm guessing that result holds the value of the current token.. right?
My understanding is the token is a string, not a number, switch() takes a number.
Personally I would not do it like that....
I would have a loop what reads a logical line and splits it up into basically an argc/argv type array. Then check argv and match it in a table, if it's in the table, the table will have a function pointer to a handler, if not then just fork/exec and the argc/argv is already setup.
When you want to add macro expansion etc, just plonk that in the logical read line.