@foone
It's useful with its opposite, strcspn, to write a tokenizer:
start = string + strspn(string, delim); // find first non-delimiter character
len = strcspn(start+1, delim);
Now you have a string with a known length that you can process.
You could use strtok, but (a) that modifies the string, which is not always what you want, and (b) is not thread-safe; strspn and strcspn are.
It's useful with its opposite, strcspn, to write a tokenizer:
start = string + strspn(string, delim); // find first non-delimiter character
len = strcspn(start+1, delim);
Now you have a string with a known length that you can process.
You could use strtok, but (a) that modifies the string, which is not always what you want, and (b) is not thread-safe; strspn and strcspn are.
- replies
- 0
- announces
- 0
- likes
- 0