title: C++: 0xC0000005: Access violation writing location 0x00000000
body: <p>I was wondering if I can get some help on my program. As stated in the title, I'm getting an access violation in my program. I realize that it has something to do with dereferencing a garbage pointer, and I'm pretty sure I've narrowed down the line that its breaking on, I'm just not sure why it's actually breaking, and how to fix it. The code is as follows:</p>
  
  <pre><code>void determineInputType(char input[kMaxUserInput])
  {
      char* flag = NULL;
      if (*(flag = strchr(input, '.')) != NULL)
      { 
          double grade = 0;
          if ((sscanf(input, "%lf", grade)) == 1)  // problem is on this line
          {
          //rest of the code continues here
  </code></pre>
  
  <p>How I'm getting the input is here:</p>
  
  <pre><code>void getUserInput(char* userInput)
  {
      printf("Enter a student's grade: ");
      fgets(userInput, kMaxUserInput, stdin);
      clearCRLF(userInput);
  
  }
  </code></pre>
  
  <p>and finally the main:</p>
  
  <pre><code>int main(void)
  {
      char userInput[kMaxUserInput] = { 0 };
      getUserInput(userInput);
      determineInputType(userInput);
  
      return 0;
  }
  </code></pre>
  
  <p>Any help on this would be greatly appreciated as it's been stumping me for a while. Thanks so much for your time, if there's anything else I need to post, let me know.</p>