title: What does `scanf("%*[^\n]%*c")` mean?
body: <p>I want to make a loop in C that, when the program asks for an integer and the user types a non-digit character, the program asks again for an integer.</p>
  
  <p>I just found the below code. but I don't understand what this means <code>scanf("%*[^\n]%*c")</code>. What does <code>^\n</code> mean? What does the <code>*</code> before <code>^\n</code> and <code>c</code> mean?</p>
  
  <pre><code>/*
  
   This program calculate the mean score of an user 4 individual scores,
   and outputs the mean and a final grade
   Input: score1, score2,score2, score3
   Output: Mean, FinalGrade
  
  */
  #include &lt;stdio.h&gt;
  //#include &lt;stdlib.h&gt;
  
  int main(void){
    int userScore = 0; //Stores the scores that the user inputs
    float meanValue = 0.0f; //Stores the user mean of all the notes
    char testChar = 'f'; //Used to avoid that the code crashes
    char grade = 'E'; //Stores the final 
    int i = 0; //Auxiliar used in the for statement
  
    printf("\nWelcome to the program \n Tell me if Im clever enough! \n Designed for humans \n\n\n");
    printf("Enter your 4 notes between 0 and 100 to calculate your course grade\n\n");
  
    // Asks the 4 notes. 
    for ( ; i&lt;=3 ; i++ ){
      printf("Please, enter your score number %d: ", i+1);
  
      //If the note is not valid, ask for it again
  
      //This is tests if the user input is a valid integer.
      if ( ( scanf("%d%c", &amp;userScore, &amp;testChar)!=2 || testChar!='\n')){
        i-=1;
        scanf("%*[^\n]%*c");
  
      }else{ //Enter here if the user input is an integer
        if ( userScore&gt;=0 &amp;&amp; userScore&lt;=100 ){
      //Add the value to the mean
      meanValue += userScore;
        }else{ //Enter here if the user input a non valid integer
      i-=1;
      //scanf("%*[^\n]%*c");
        }    
      }
    }
  
    //Calculates the mean value of the 4 scores
    meanValue = meanValue/4;
  
    // Select your final grade according to the final mean
    if (meanValue&gt;= 90 &amp;&amp; meanValue &lt;=100){
      grade = 'A';
    } else if(meanValue&gt;= 80 &amp;&amp; meanValue &lt;90){
      grade = 'B';
    } else if (meanValue&gt;= 70 &amp;&amp; meanValue &lt;80){
      grade = 'C';
    } else if(meanValue&gt;= 60 &amp;&amp; meanValue &lt;70){
      grade = 'D';
    }
    printf("Your final score is: %2.2f --&gt; %c \n\n" , meanValue, grade);
  
    return 0;
  }
  </code></pre>