title: Getting : " STATUS_ACCESS_VIOLATION" when attempting to compile this C++ code
body: <p>What could be the problem? I thought it might have been with initializing the pointer when I used strtok, but that did not fix the problem. Sorry if this is dumb, I am very new to this.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;cstring&gt;
  #include &lt;cstdlib&gt;
  #include &lt;algorithm&gt;
  #include &lt;iomanip&gt;
  using namespace std ;
  
  int main() {
  
  //initialize and get input into a string, turn into a cstring
      string intstring ;  
      cout &lt;&lt; "Enter five integers: " ;
      cin &gt;&gt; intstring ;
      char * cstr = new char [intstring.length()+1];
      strcpy (cstr, intstring.c_str());
  
  //use strtok to convert into an array of strings
      int intarray[5] ;
      char * point = strtok ( cstr , " " ) ;;
      int i = 0 ;
      while ( point != NULL ) {
          intarray[i] = atoi ( point ) ;
          point = strtok ( cstr , " " ) ;
          i++ ;
          }
  
  //get the sum of all integers
  int sum = 0;
      for (int i = 0; i &lt; 5 , i++ ;) {
          sum += intarray[i] ;    
      }   
  
  //sort the array of integers
  sort(intarray, (intarray + 5)) ;
  
  //print the mean and median
      cout &lt;&lt;  "Median is " &lt;&lt; intarray[2] &lt;&lt; endl;
      cout &lt;&lt; "Geometric mean is " ;
      cout &lt;&lt; (sum / 5) &lt;&lt; setprecision(4);
  
      return (0) ;
      }
  </code></pre>