globus243

(nicht fertig) Hangsman

Aug 23rd, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.75 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <windows.h>
  7. #include <ctype.h>
  8.  
  9. void gotoxy(int x, int y)
  10. {
  11. COORD coord;
  12. coord.X = x;
  13. coord.Y = y;
  14. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  15. }
  16.  
  17. int main()
  18.  
  19. {
  20.     char word[81], used[14];
  21.     int wrong=0, laenge, _, i;
  22.     char input;
  23.    
  24.    
  25.     SetConsoleTitle(" Guess me if u Can! ");
  26.  
  27.  
  28.    
  29.     //printf("\n\n spielst du mit einem Freund oder alleine?");
  30.     //printf(" \n\n [1] alleine"
  31.     //       " \n\n [2] mit einem Freund");
  32.  
  33.    
  34.     printf("\n\n please insert a word (max. 80 characters): \n\n");
  35.    
  36.     gets(word);
  37.    
  38.         laenge=strlen(word);
  39.        
  40.         printf("\n\n this word has %i characters.\n\n",laenge);
  41.        
  42.         for(i=0; i<13; i++)
  43.         {
  44. //                    for(_=0; _<laenge; _++)
  45. //                    printf(" _");
  46. //                    printf("\n");
  47.      
  48.         gotoxy(10,10);
  49.         printf("\n\n please insert a letter now:  ");
  50.         input=getch();
  51.         strcpy(used, &input);
  52.         printf("\n\n The following characters are allready used: %c ", used);
  53.                
  54.         if(strchr(word, input)){
  55.                           printf("\n\n %c is in the word\t\t\t\t\t\t\n\n");
  56.                           i--;
  57.                          
  58.         }
  59.                       else{
  60.                           printf("\n\n the letter %c is wrong!\n");
  61.                           wrong++;
  62.                           printf(" you have %i try",13-wrong);
  63.         }
  64.        
  65.       }
  66.         system("cls");
  67.         printf("\n\n to many tries.\n\n");
  68.        
  69.        
  70.                                              
  71.  
  72.    
  73.     system("Pause");
  74.  
  75.        
  76. }
Advertisement
Add Comment
Please, Sign In to add comment