示例#1
0
文件: WordGame.c 项目: kimtu/Projects
void play_word_game(void) {
	char word_list[TOTAL_COUNT][MAX_WORD] = {""};
	char read_word[MAX_WORD] = "";
	char working_word[MAX_WORD] = ""; 
	char c;
	int word_count;
	int score = 0;
	int win_score;
	int find_flag;

	srand( (unsigned int) time(NULL));
	printf("time...%d\n", (unsigned int)time(NULL));

	word_count = read_word_list("wordlist.txt", word_list);

	while(1) {
		printf("Current Score is : %d \n", score);
		printf("Figure it out!!!...\n");

		get_new_word(word_list, word_count, read_word);

		init_working_word(read_word, working_word);

		win_score = 100;

		while(1) {
			display_word(working_word);
			
			c = getch();
			if(c==ESC) {
				return;
			}
			printf("%c\n", c);

			find_flag = find_word(c, read_word, working_word);

			if (is_word_complete(read_word, working_word)) {
				display_word(working_word);
				printf("Success !!! \n\n");
				score += win_score;
				break;
			}

			if (find_flag == FALSE && win_score-5>=0) {
				win_score -=5;
			}
		}

		
	}
}
示例#2
0
文件: autocomplete.c 项目: Yopes/42sh
static char	*autocomplete_replace(char *str, t_bin *bin,
				      int *index, t_cmd *cmd)
{
  char		*new_word;

  if ((new_word = get_new_word(bin)) != NULL)
    {
      if (*index != 0 && is_alpha(str[*index - 1]) == 1)
	str = gere_alt_back(index, str, cmd);
      str = put_in_str(str, *index, new_word);
      free(new_word);
    }
  return (str);
}