Get words (actual words) from a char array and see if it's in another char array

Thanks for your reply. With your advice it partially works now, thanks. Though, it only says the first 2 or three letters of the word. Any idea? Thanks.

String compare(char* x){
  String lastcommand;
  for(int i = 0; i<sizeof(x); i++){
    if(x[i] == ' ')
    break;
    lastcommand += x[i];
    }
    return lastcommand;
  }