Hello everyone,
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:
Code:
#include <stdio.h>
int main(void)
{
char buf[128];
printf("Please enter a command: ");
gets(buf);
if(!strcmp(buf, "command1")) puts("do something");
if(!strcmp(buf, "command2")) puts("do something else");
if(!strcmp(buf, "command3")) puts("....");
return 0;
}
How could I make it so that it would accept an input like: command1 | command3
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.
Best regards,
apsync.