title: Why does this code give me a SIGABRT error? C Programming
body: <pre><code>#include &quot;framework.h&quot;
  #include &lt;stdio.h&gt;
  //-----------------------------------------------------------------------------
  // Computes and returns the length of a string
  //
  // @param text string to check
  //
  // @return length of the string
  //
  int stringLength(char *text);
  
  //-----------------------------------------------------------------------------
  // Changes a string to upper case
  //
  // @param text string to modify
  //
  void toUpper(char *text);
  
  
  //-----------------------------------------------------------------------------
  int stringLength(char *text)
  {
      int  string_length = 0;
  
      while (text[string_length] != '\000')
          string_length++;
  
      return string_length;
  }
  
  // Main Function
  //
  int main()
  {
      char key[MAX_KEY_LENGTH] = {};
      int string_len = 0;
  
      do {
          printf(KEY_PROMPT);
          gets(key);
          string_len = stringLength(key);
          if (string_len &lt;= MAX_KEY_LENGTH &amp;&amp; string_len &gt; 0)
          {
              break;
          }
      } while (string_len &gt; MAX_KEY_LENGTH || string_len &lt; 0);
  }
  </code></pre>
  <p>This is my code.
  Always when i first put in a string thats too long
  (eg. &quot;Student StudentStudent StudentStudent StudentStudent StudentStudent Student&quot;)
  and then one which is &quot;correct&quot;
  (eg. &quot;Student Student&quot;)</p>
  <p>it gives me this error: (look at picture)</p>
  <p><a href="https://i.stack.imgur.com/0jEsO.png" rel="nofollow noreferrer">error code</a></p>