title: looping a program that converts to uppercase and shifts 4 letter grades in C
body: <p>This program calls two functions uppercase(), which converts the input to uppercase, and shift(), which shifts the grade input. </p>
  
  <p>Here's my uppercase() function:</p>
  
  <pre><code>void uppercase(char *p)
  {
  
   if(islower(*p)) {
      *p = toupper(*p);
      }
  
  }
  </code></pre>
  
  <p>Here's the shift() function:</p>
  
  <pre><code>void shift(char *p1, char *p2, char *p3, char *p4)
  {
   int count = 0;
   do {
   ++count;
   char tmp;
   tmp = *p4;
   *p4 = *p3;
   *p3 = *p2;
   *p2 = *p1;
   *p1 = tmp;
   printf("Grades Shifted #%i:   %c %c %c %c \n", count, *p1, *p2, *p3, *p4);
   } while (count &lt; 4);
  
  }
  </code></pre>
  
  <p>Here's my main function. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  main (void)
  {
   float choice;
  
   do {
   char c1, c2, c3, c4;
   printf ("Enter 4 letter grades to find statistics: ");
   scanf("%c %c %c %c", &amp;c1, &amp;c2, &amp;c3, &amp;c4);
   getchar();
  
   uppercase(&amp;c1);
   uppercase(&amp;c2);
   uppercase(&amp;c3);
   uppercase(&amp;c4);
  
   printf("Input Grades: %c %c %c %c\n", c1, c2, c3, c4);
   shift(&amp;c1, &amp;c2, &amp;c3, &amp;c4);
   printf("Want to shift more grades (y/n)? ");
   choice = getchar();    
   } while ( choice == 'y' || choice == 'Y');
  getchar();
  
  }
  </code></pre>
  
  <p>My output looks like this</p>
  
  <blockquote>
    <p>Enter 4 letter grades to find statistics: abcd<br>
    Input Grades: A B C D<br>
    Grades Shifted #1:   D A B C<br>
    Grades Shifted #2:   C D A B<br>
    Grades Shifted #3:   B C D A<br>
    Grades Shifted #4:   A B C D<br>
    Want to shift more grades (y/n)? y<br>
    Enter 4 letter grades to find statistics: adff<br>
    Input Grades:<br>
     A D F<br>
    Grades Shifted #1:   F<br>
     A D<br>
    Grades Shifted #2:   D F<br>
     A<br>
    Grades Shifted #3:   A D F<br>
    Grades Shifted #4:<br>
     A D F<br>
    Want to shift more grades (y/n)?</p>
  </blockquote>
  
  <p>The format gets messed up on the second input, and when I input another y after the second input, the program closes. I've been tinkering with this for the past hour and I can't figure out why my formatting gets messed up or why the loop closes/crashes on the third attempt. </p>
  
  <p>Also how can I make it so that my main function only accepts inputs of A-D or F. </p>
  
  <p>Thanks.</p>