title: How to use an edit conversion code in a scanf function to stop scanning a string at a specific word
body: <p>I was wondering how to use an edit conversion code in a scanf function to stop scanning a string at a specific word (as the title says). I had an idea of how this would most likey work but it's not working how I intended it to.</p>
  
  <pre><code>#include &lt;stdio.h&gt;  
  
  int main(void) 
  { 
      char name[50]; 
      printf("Say your message: ");
      scanf("%[^ over]", name); 
      printf("Received message: %s\n", name);
  
      return 0;
  }
  </code></pre>
  
  <p>Which gives me to following output with the input of "I'm almost there over"</p>
  
  <pre><code>/* 
  Say your message: I'm almost there over
  Received message: I'm
  */
  </code></pre>
  
  <p>I understand that what it's doing is checking where the first time any of the chars ' '(space char),'o','v','e' or 'r' come first and stop scanning once it hits any of these characters.  This is why it stops at the end at I'm, it runs into the space char and stops scanning.</p>
  
  <p>I don't know how to properly write this in a way where the output is "I'm almost there". I know there's definitely a not hard way to do this with for loops but I was wondering how you would do only using this method. Does anyone know how to do this?</p>