Techhgeekz ™

Saturday 31 August 2013

guessing a word with three times

guessing a word with three times in c using functions:-

#include <stdio.h>
#include <string.h>
void get_user_input(char *guess[10]);
int main(void)
{
const char secret[10] = "dinesh dk";
char guess[10];
int i;
for (i=0; i < 3; i++)
{
 get_user_input(guess);
 if (strcmp(secret, guess)==0)
 {
   printf("Your guess was correct");
   return 0;
 }
  else
 {
   printf("Your guess was incorrect. Please try again\n");
 }
 } 
return 0;
}
void get_user_input(char *guess[10])

 printf("Please guess the word: \n");
 scanf("%s", guess);
}

No comments:

Post a Comment