I am trying to make my program so that it can listen to multiple commands seperated by a character.
Lets say I have a simple program like this:
How could I make it so that it would accept an input like: command1 | command3
printf("Please enter a command: ");
if(!strcmp(buf, "command1")) puts("do something");
if(!strcmp(buf, "command2")) puts("do something else");
if(!strcmp(buf, "command3")) puts("....");
I was thinking of using strchr, but how can I make it so that it compares to the buf, can anyone provide an example, that would be great.