title: C: Incorrect characters are being printed, suspected mem. issue
body: <p>I am running into something interesting, where weird characters are getting printed instead of what I am expecting. It was not doing this earlier, but I started playing around with the fgets and sscanf and now it will not return to the way it was. I'm guessing I corrupted memory somewhere, or left something in the stdin buffer, but not really sure. Any ideas?</p>
  
  <p>What I am expecting:</p>
  
  <pre><code>***************************************************************************
  *                                                                         *
  *                                                                         *
  *    1) What char for border?                                             *
  *    2) Add question                                                      *
  *    3) Remove Question                                                   *
  *    4) Print last answers                                                *
  *    5) Exit                                                              *
  *                                                                         *
  *                                                                         *
  *                                                                         *
  *                                                                         *
  ***************************************************************************
  </code></pre>
  
  <p>What is actually printing (as you can see, it's printing a funky y and consuming a space):</p>
  
  <pre><code>***************************************************************************
  *                                                                         *
  *                                                                         *
  *    1) What char for border?                                             *
  *    2) Add question                                                      *
  *    3) Remove Question                                                   *
  *    4) Print last answers                                                *
  *    5) Exit                                                              *
  *                                                                         *
  *    ÿ                                                                   *
  *                                                                         *
  *                                                                         *
  ***************************************************************************
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  typedef struct f_in{
      char outline;
      int lines;
      int rows;
      int num_args;
  } F_IN;
  
  typedef struct args_in {
      char in_string[20];
      int t_format;
  } ARGS_IN;
  
  void printInterface(char argQs[5][50], char argChar);
  
  int main(int argv, char** argc){
      char defaultQuestions[5][50] = { { "1) What char for border?" }
          , { "2) Add question" }
          , { "3) Remove Question" }
          , { "4) Print last answers" }
      , { "5) Exit" } };
      int commandEntry, exitFlag, i;
      char borderChar = '*', addQ[50], userInp[10];
  
      exitFlag = 1;
  
      while (exitFlag){
          printInterface(defaultQuestions, borderChar);
  
          // GET INITIAL INPUT FROM USER
          printf("Enter the integer value for the command you wish to select:  ");
          fgets(userInp, sizeof(userInp), stdin);
          // VERIFY INPUT IS VALID
          sscanf(userInp, "%d", &amp;commandEntry);
          printf("\nYou selected: %s\n", defaultQuestions[commandEntry - 1]);
  
          if (commandEntry == 1){
              printf("Please enter the character you wish to be the border:  ");
              scanf("\n%c", &amp;borderChar);
          }
          else if (commandEntry == 2){
              printf("What question would you like to add? (only enter 50 char max)\n");
              fgets(addQ, 50, stdin);
              printf("This was your question: %s", addQ);
          }
          else if (commandEntry == 5){
              printf("Goodbye!\n");
              exitFlag = 0;
          }
      }
      return 0;
  
  }
  
  void printInterface(char argQs[5][50], char argChar){
      int i, j;
      int lineCnt = 13;
      int borderLen = 75;
  
      for (i = 0; i&lt;100; i++){
          printf("\n");
      }
  
      for (i = 0; i&lt;lineCnt; i++){
  
          if (i == 0 || i == lineCnt - 1){
              for (j = 0; j&lt;borderLen; j++){
                  printf("%c", argChar);
              }
              printf("\n");
          }
  
          else if (i &gt;= 3 &amp;&amp; i &lt;= 10){
              printf("%c    %s", argChar, argQs[i - 3]);
              for (j = 0; j &lt; ((borderLen - strlen(argQs[i - 3]))-6); j++){
                  printf(" ");
              }
              printf("%c\n", argChar);
          }
  
          else{
              for (j = 0; j&lt;borderLen; j++){
                  if (j == 0){
                      printf("%c", argChar);
                  }
                  else if (j == (borderLen - 1)){
                      printf("%c\n", argChar);
                  }
                  else{
                      printf(" ");
                  }
              }
          }
      }
  
      for (i = 0; i&lt;10; i++){
          printf("\n");
      }
  
  }
  </code></pre>