I am trying to separate a string into multiple strings, to make a customized terminal. So far I have been separating control signals using strtok, however I do not understand how to separate specific instances of a character. For example:
string input = "false || echo \"hello world\" | grep hello";
When trying to strtok this input
and trying to separate using |
the output would be:
false
, echo "hello world"
, grep hello
Instead, I would like the output to be:
false || echo "hello world"
, grep hello
How can I have strtok treat |
and ||
differently rather than having it saying they are the same?
strtok
considers each character in the second argument to be a delimeter. Also, it does not return an empty string. Related 1,2 – January