/ Published in: C
Expand |
Embed | Plain Text
#include <stdio.h> #include <string.h> #include <time.h> /* --------------------------- GENERATE_ANSWER --------------------------- */ int generate_answer ( char* answer ) { char* dictionary[] = { "suck", "porn", "linux", "gcc", "shit", NULL }; srand ( time(NULL) ); strcpy ( answer, dictionary[rand() % 5] ); return 0; } /* ---------------------------- ANALYZE_WORD ---------------------------- */ int analyze_word ( const char* user_word, const char* answer ) { int ii = 0, right_chars = 0; for ( ii = 0; user_word[ii] != '\0'; ii++ ) if ( user_word[ii] == answer[ii] ) { right_chars++; ii, answer[ii] ); // DEBUG } return 0; } /* -------------------------------- MAIN -------------------------------- */ int main() { char answer[32], user_word[32]; generate_answer ( & answer ); while (1){ gets ( & user_word ); if ( !strcmp(answer, user_word) ) { puts( "win!" ); break; } else analyze_word (user_word, answer); } return 0; }
You need to login to post a comment.
