cstrtokstrsep

What are the differences between strtok and strsep in C


Could someone explain me what differences there are between strtok() and strsep()? What are the advantages and disadvantages of them? And why would I pick one over the other one.


Solution

  • From The GNU C Library manual - Finding Tokens in a String:

    One difference between strsep and strtok_r is that if the input string contains more than one character from delimiter in a row strsep returns an empty string for each pair of characters from delimiter. This means that a program normally should test for strsep returning an empty string before processing it.