title: User defined function - returning a pointer / string
body: <p>Can anyone point out the obvious? I can't seem to find what I've done wrong.</p>
  <p>This code produces quite a bit of a pause followed by no visible output. Debug crashes so it's a real good attempt.</p>
  <p><strong>Edit;
  The intents just to understand how to output a char via a user defined function when a int is passed to it. eg you enter a test score of 85 printf should print HD.
  I had no idea getchar() was ASCII value, this might explain the output I was getting earlier. Thanks Bodo.</strong></p>
  <p>If I change the printf - %d I do get numbers so thought I was getting ASCII but they have not added up to something I've been able to decrypt. Numerical entry of 85 = 100 &amp; 65 = 104</p>
  <p>If it's super wrong let me know and I'll go back and make this code work without a user defined function first.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt; 
  
  char determine_grade(int test_score);
  
  int main()
  {
      int test_score = 0;
      char *test_result;
  
      printf(&quot;enter test score:&quot;);
      test_score =getchar();
  
      test_result = determine_grade(test_score);
  
      printf(&quot;grade is: %s&quot;, test_result);
  
      return 0;
  }
  
  char determine_grade(int test_score)
  {
      char *test_result;
          if (test_score &gt;= 85)
          test_result = &quot;HD&quot;;
      else if (test_score &gt;= 75)
          test_result = &quot;D&quot;;
      else if (test_score &gt;= 65)
          test_result = &quot;C&quot;;
      else if (test_score &gt;= 55)
          test_result = &quot;P1&quot;;
      else if (test_score &gt;= 50)
          test_result = &quot;P2&quot;;
      else if (test_score &gt;= 40)
          test_result = &quot;F1&quot;;
      else
          test_result = &quot;F2&quot;;
      
      return test_result;
  }
  </code></pre>