title: Searching for block of characters (word) in a text
body: <p>I want to search for a block of characters (word) in a text.<br />
  For example, I have the next text &quot;Hello xyz world&quot;, and I want to search for &quot;xyz &quot;, note the space after the word.</p>
  <pre><code>// The Text
  const char * text = &quot;Hello xyz world&quot;;
  // The target word
  const char * patt = &quot;xyz &quot;;
  size_t textLen = strlen(text),
    pattLen = strlen(patt), i, j;
  
  for (i = 0; i &lt; textLen; i++) {
    printf(&quot;%c&quot;, text[i]);
    for (j = 0; j &lt; pattLen; j++) {
      if (text[i] == patt[j]) {
        printf(&quot; &lt;--&quot;);
        break;
      }
    }
    printf(&quot;\n&quot;);
  }
  </code></pre>
  <p>The result must be like following:</p>
  <p><a href="https://i.stack.imgur.com/OhCYC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OhCYC.jpg" alt="" /></a></p>
  <p>But unfortunately, the result as the following:</p>
  <p><a href="https://i.stack.imgur.com/oKEpv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oKEpv.jpg" alt="" /></a></p>
  <p>It collects all the similar characters in the whole text, not just the target characters (the word).</p>
  <p>How to fix that problem?</p>