title: How to make the program stop reading the codes?
body: <p>What I want to do is: The user inputs a string; for example: <code>12345,44,55,66</code>. I've created a function to check if the first 5 characters aren't digits, then the program will output an error message and if the 6th character is not <code>,</code>, the program will also output an error message. My problem is that I want the program to stop reading the codes if an error is detected (won't print if there is an error). So how I can stop the program from continuing reading the codes? Here is what I have written so far.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  
  void checkstudentID(char temp[]);
  
  main()
  {
      char temp[10000];
      char m0[10000];
      gets(temp);
      checkstudentID(temp);   
      printf("%s",temp);          
      return 0;
  }
  
  void checkstudentID(char temp[])
  {
      int i;
      for (i=0;i&lt;6;i++)
      {
          if (isdigit(temp[i]) == 0)
          {
              printf("Student ID must contain only integers.\n");
              return 0;
          }
      }
      if (temp[6] != *(","))
      {
                printf("Student ID must contain only 6 integers.\n");
                return 0;
      }
  }
  </code></pre>