isn't it the same as 
if ( char* space = strchr(name, ' ') ) 
  name[space - name] = '\0';