title: Tips on how to read last 'word' in a character array in C
body: <p>Just looking to be pointed in the right direction:</p>
  
  <p>Have standard input to a C program, I've taken each line in at a time and storing in a char[].</p>
  
  <p>Now that I have the char[], how do I take the last word (just assuming separated by a space) and then convert to lowercase?</p>
  
  <p>I've tried this but it just hangs the program:</p>
  
  <pre><code>while (sscanf(line, "%s", word) == 1)
      printf("%s\n", word);
  </code></pre>
  
  <p>Taken what was suggested and came up with this, is there a more efficient way of doing this?</p>
  
  <pre><code>char* last = strrchr(line, ' ')+1;
  
  while (*last != '\0'){   
      *last = tolower(*last);
      putchar((int)*last);
      last++;
  }
  </code></pre>