title: Is there a way to print only the first word of a string with gets() in C?
body: <p>I am very new to programming and i wonder if there is a way to print out the first word of a string with gets() in C?</p>
  
  <pre><code>void printFirstWord(char string[])
  {
      int i;
  
  for(i = 0; i &lt; (string[i] != '\0'); i++)
      {
      if(isalpha(string[i]))
          printf("%c", string[i]);
      }
  
  
  }
  
  int main()
  {
  
  char string[MAX];
  printf("Type in a scentence");
  gets(string);
  printFirstWord(string);
  
  
  return 0;
  }
  </code></pre>
  
  <p>This is the function that i have written and called in main right now. Is it because i have isalpha in the function?</p>