| Refresh | Home EGTry.com

get the first word from a string sentence


//extract the first chunk of non-space characters
#include <stdio.h>



int main()
{

   char *name;
   char *first;

   name="Hello World";
   printf("name=%s\n", name);
  
   first=name;  
   while( (*name) && (! (isspace(*name))) )
     name++;
   *name='\0';

   printf("first word=%s\n", first);
}