title: Understanding strspn(const char *s, const char *accept) function
body: <p>I am writing a program that reads a file line by line to separate word and translation. The code below works. However I am unable to understand how <code>/* separate word and translation */</code> part of the <code>load_dictionary</code> function actually works. <a href="https://i.stack.imgur.com/PAoFa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PAoFa.png" alt="I ran it through **gdb**"></a>.</p>
  
  <p><strong>Things unclear</strong>:</p>
  
  <ul>
  <li>output of <code>p line</code></li>
  <li>output of <code>p word</code> after <code>word = line + strspn(line, DELIMS)</code>. Isn't <code>strspn</code> supposed to read till <code>DELIMS</code> \t and print - <em>ants\t</em>.</li>
  </ul>
  
  <p><strong>FILE:</strong> dict.txt</p>
  
  <pre><code>WORD    TRANSLATION
  
  ants    anttt
  anti    eti
  ante    soggy
  anda    eggs
  </code></pre>
  
  <p>Function: <strong>main</strong></p>
  
  <pre><code> /* maximum number of characters for word to search */
   #define WORD_MAX 256
  
   /* maximum number of characters in line */
   #ifndef LINE_MAX
   #define LINE_MAX 2048
   #endif
  
   int main(int argc, char * argv[]) {
          char word[WORD_MAX], * translation;
          int len;
  
          if (argc &lt;= 1)
              return 0; /* no dictionary specified */
  
          /* load dictionary */
          load_dictionary(argv[1]);
          return 0;
    }
  </code></pre>
  
  <p>Function: <strong>load_dictionary</strong>:- <em>read dictionary file</em></p>
  
  <pre><code>/* delimiter for dictionary */
  #define DELIMS "\t"
  
  unsigned void load_dictionary(const char * filename) {
          FILE * pfile;
          char line[LINE_MAX], * word, * translation;
  
          /* ensure file can be opened */
          if ( !(pfile = fopen(filename,"r")) )
              return icount;
  
          /* read lines */
          while ( (fgets(line, LINE_MAX, pfile)) ) {
              /* strip trailing newline */
              int len = strlen(line);
              if (len &gt; 0 &amp;&amp; line[len-1] == '\n') {
                line[len-1] = '\0';
                --len;
              }
  
              /* separate word and translation */
              word = line + strspn(line, DELIMS);
  
              if ( !word[0] )
                  continue; /* no word in line */
              translation = word + strcspn(word, DELIMS);
              *translation++ = '\0';
              translation += strspn(translation, DELIMS);
          }
   }
  </code></pre>