title: Moving a figure in console C++
body: <p>Im writing a program, which is supposed to print <code>"X'</code> made of ASCII chars in the console, change size and allow to move it with keys. I know how to print this X and change a size, but I'm totally stuck and i don't know how to move it.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  #include &lt;Windows.h&gt;
  
  void Intro();
  void Draw();
  
  const int Esc = 27;
  
  int main()
  {
  Intro();
  Draw();
  
  return 0;
  }
  
  void Intro()
  {
  std::cout &lt;&lt; "Napisz program rysowania znakiem ponizszej figury:\n";
  std::cout &lt;&lt; "    *    * \n";
  std::cout &lt;&lt; "     *  *  \n";
  std::cout &lt;&lt; "      *    \n";
  std::cout &lt;&lt; "     *  *  \n";
  std::cout &lt;&lt; "    *    * \n";
  
  std::cout &lt;&lt; std::endl;
  
  std::cout &lt;&lt; "Program powinien umozliwiac:\n"
      &lt;&lt; " - Wybor znaku kodu ASII,\n"
      &lt;&lt; " - Wczytanie poczatkowych rozmiarow figury,\n"
      &lt;&lt; " - Zmiane wielkosci figury klawiszami '+' i '-',\n"
      &lt;&lt; " - Przesuwanie figury w czterech kierunkach za pomoca kursorow,\n"
      &lt;&lt; " - Ograniczenie przesuwania i rozmiarow figury do obszaru ekranu.\n";
  
  _getch();
  
  return;
  }
  
  void Draw()
  {
  int Size;
  char AsciiChar;
  char Tab[50][80];
  int AsciiCharPosX = 0;
  int AsciiCharPosY = 0;
  char Key;
  
  system("cls");
  
  std::cout &lt;&lt; "Enter the size: ";
  std::cin &gt;&gt; Size;
  std::cout &lt;&lt; std::endl;
  std::cout &lt;&lt; "Enter the ASCII char from the keyboard: ";
  std::cin &gt;&gt; AsciiChar;
  std::cout &lt;&lt; std::endl;
  
  for (int i = 0; i &lt; Size; i++)
  {
      for (int j = 0; j &lt; Size; j++)
      {
          Tab[i][j] = 'e';                                    // e - empty field
      }
  }
  Tab[AsciiCharPosX][AsciiCharPosY] = 'f';                    //f - filled
  
  do
  {
      system("cls");
  
      for (int Rows = 1; Rows &lt;= Size; Rows++)
      {
          for (int Cols = 1; Cols &lt;= Size; Cols++)
          {
              if (Rows == Cols || Cols == (Size + 1) - Rows)
              {
                  Tab[Rows][Cols] = 'f';
                  if (Tab[Rows][Cols] == 'f')
                  {
                      std::cout &lt;&lt; AsciiChar;
                  }
              }
              else
              {
                  Tab[Rows][Cols] = 'e';
                  if (Tab[Rows][Cols] == 'e')
                  {
                      std::cout &lt;&lt; " ";
                  }
              }
          }
          std::cout &lt;&lt; std::endl;
      }
  
      Key = _getch();
  
      switch (Key)
      {
      case '+':
      {
          Size = Size + 2;
          break;
      }
      case '-':
      {
          Size = Size - 2;
          break;
      }
      case 's':
      {
          AsciiCharPosY++;
          break;
      }
      case 'w':
      {
          AsciiCharPosY--;
          break;
      }
      case 'a':
      {
          AsciiCharPosX--;
          break;
      }
      case 'd':
      {
          AsciiCharPosX++;
          break;
      }
      }
  } while (Key != Esc);
  
      return;
  }
  </code></pre>