title: How to return char value in a function and store it in the main function
body: <p>create function that prompts the user to enter a single character. The return value of the function be a <code>char</code> and will return the character value entered by the user.T his return value will be stored in a local variable, C, in <code>main()</code>. The initial default value of this character will be ' '. The question is how would I store it in the main if the local variable C is not global, and we cannot make it global. I have to use that C variable to finish my other functions. Here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  char enterSingleChar();
  
  int main()
  {       
          char userChoice;
          int N = 0;
          char C = ' ';
  
          printf("Please choose one of the following choices below \n");
          printf("Enter/Change Character (C/c)\n");
          printf("Quit Program (Q/q) \n");
  
          scanf("%c", &amp;userChoice);
  
          switch(userChoice)
          {       
                  case 'C':
                  case 'c':
                          enterSingleChar();
                          break;
                  case 'Q':
                  case 'q':
                          printf("The program will now quit\n");
                          exit(1);
                  default:
                          break;
          }
  }
  
  char enterSingleChar()
  {
          char singleChar = ' ';
          printf("Please enter a single character \n");
          scanf(" %c", &amp;singleChar);
          return singleChar;
  }
  </code></pre>