title: How to use arrays in Hangman game C
body: <p>Don't know how to solve it further. </p>
  
  <pre><code> #include&lt;stdio.h&gt;
   #include&lt;conio.h&gt;
   #include&lt;stdlib.h&gt;
   #include&lt;string.h&gt;
  
   void main()   
   {
  
      printf( "                  Welcome To Hangman!:)           \n");
      printf( " All the Best (y)   \n");
      printf( "You can play it 3 time \n");
      printf( "You have 6 chances for wrong guesses\n");
  
      int x=0;
      while (x&lt;3)
      {
          char word[]="pakistan";
          /*
          string[1]="india";
          string[2]="america";
          string[3]="aferica";
          string[4]="spain";
          string[5]="china";
          int wrong = 1;
          char word=rand()%5;
          */
          int wrong=0;
          int new=0;
          char so_far[strlen(word)];
          int I;
          for(I=0; I&lt;strlen(word); I++)
          {
              so_far[I] = '_';
          }
  
  
          while(wrong&lt;=7 &amp;&amp; strcmp(so_far, word)!=0)
          {
              printf("so far the word is: %c\n", so_far);
              char guess;
              printf("enter your guess: ");
              scanf("%c", &amp;guess);
              //guess=guess.upper();
  
              int i=0;
              //if (new==1)
          //  {
  
  
              for(i=0;i&lt;strlen(word);i++)
                      {
                          if (word[i]==guess)
  
                  //  if (guess==word[i])
  
                          //new+=guess;
                          so_far[i]=guess;
                          new=1;
  
                  //  else
  
                      //  new+=so_far[i];
                  }
  
  
          //  so_far[i]=new;
          //  }
              //else
              if(new!=1)
              {
                  printf("\nsorry '%c' is not in the word\n",guess);
                  printf("\nyour wrong guesses are: %d\n",wrong);
                  if (wrong ==1)
                      {
                              printf("\n      +------- \n");
                              printf("       |   |  \n");
                              printf("       |   O  \n");
                              printf("       |    \n");
                              printf("       |    \n");
                              printf("       |    \n");
                              printf("       |    \n");
                              printf("       |    \n");
                              printf("       =============\n");
                  }
                  if( wrong==2)
                  {
                          printf("\n       +------- \n");
                          printf("       |   |  \n");
                          printf("       |   O  \n");
                          printf("       |   | \n");
                          printf("       |   | \n");
                          printf("       |    \n");
                          printf("       |    \n");
                          printf("       |    \n");
                          printf("       =============\n");
                  }
              if (wrong==3)
                 {
                      printf("\n       +------- \n");
                      printf("       |    |  \n");
                      printf("       |    O  \n");
                      printf("       |    |____   \n");
                      printf("       |    | \n");
                      printf("       |    |  \n");
                      printf("       |    \n");
                      printf("       |    \n");
                      printf("       =============\n");
              }
              if( wrong==4)
                  {
                      printf("\n       +------- \n");
                      printf("       |    |  \n");
                      printf("       |    O  \n");
                      printf("       |____|____   \n");
                      printf("       |    | \n");
                      printf("       |    |  \n");
                      printf("       |    \n");
                      printf("       |    \n");
                      printf("       =============\n");
              }
              if( wrong==5)
                  {
                  printf("\n         +-------\n");
                  printf("         |     |\n");
                  printf("         |  ___O___\n");
                  printf("         |     |\n");
                  printf("         |     | \n");
                  printf("         |      |\n");
                  printf("         |      |  \n");  
                  printf("       ==============\n");
  
                  }
              if (wrong==6)
                  {
                  printf("\n         +-------\n");
                  printf("         |     |\n");
                  printf("         |  ___O___\n");
                  printf("         |     |\n");
                  printf("         |     | \n");
                  printf("         |   |   |\n");
                  printf("         |   |   |  \n");  
                  printf("       ==============\n");
              }
              //wrong+=1;
              }
          wrong+=1;
          }
          if (wrong==7)
          {
              printf("you lose and your hanged :(\n");
  
          }
          else
          {
              printf("you guessd it. Good\n");
          }
          printf("the word is: %c\n",word);
  
  
  
          x++;
          printf("play once again\n");
      }
      printf("game over\n");
      getch();
  
  }
  </code></pre>
  
  <p>The else statement is not working properly and loop of wrong&lt;7,instead of printing once, is printing twice. please help</p>