fork(1) download
  1.  
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6. const int lol[] = {10920, 11129};
  7. char secret[] = "hi";
  8. char answer[] = "__";
  9. int o_o = 2;
  10.  
  11. for (int i = 0; i < 7; ++i)
  12. {
  13. printf("Enter a letter. %s\n", answer);
  14. int guess = getchar();
  15.  
  16. if(!(lol[0] + guess*(guess - (lol[1]-lol[0]))))
  17. {
  18. answer[guess - secret[0]] = secret[guess - secret[0]];
  19. o_o -= 1;
  20. }
  21. else
  22. {
  23. printf("Letter not found, try again\n");
  24. }
  25.  
  26. if (!o_o)
  27. {
  28. printf("You win\n");
  29. break;
  30. }
  31. }
  32.  
  33. printf("The word was %s\n", secret);
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 2172KB
stdin
e
g
h
j
k
i
stdout
Enter a letter. __
Letter not found, try again
Enter a letter. __
Letter not found, try again
Enter a letter. __
Enter a letter. h_
Letter not found, try again
Enter a letter. h_
Letter not found, try again
Enter a letter. h_
You win
The word was hi