title: segmentation fault with dynamic allocation and arrays/pointers
body: <p>I'm working on an assignment that is introducing the principals of dynamic allocation of memory and pointers. I had made a simple program in the past that accepted 5 names and 5 scores and then used a selection sort to put them in descending order. My assignment now is to come back to that same program and ask the user how many scores they would like to input, then use pointers to dynamically allocate the necessary amount of memory. This is my first time working with pointers and these concepts so im still trying to figure it all out.</p>
  
  <p>I got the code to compile but I get a segmentation fault error as soon as i enter any integer number for how many scores i would like to input (which is the first thing the program asks)</p>
  
  <p>Im sure there are a few errors along the way with how i called and declared functions so if theres anything i just desperately change please let me know, but for now I dont understand why my program is crashing where it is crashing.
  Here is my code</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void initializeData(string *names[], int *scores[], int num);
  void displayData(string *names[], int *scores[], int num);
  void sortData(string *names[], int *scores[], int num);
  
  int main()
  {
  int num;
  int **intPoint;
  string **strPoint;
  
   cout &lt;&lt; "How many scores would you like to enter?: ";
   cin &gt;&gt; num;
  
   cout &lt;&lt; " core dumped? ";
  
  *intPoint = new int[num];
  *strPoint = new string[num];
  
  initializeData(strPoint,intPoint,num);
  sortData(strPoint,intPoint,num);
  displayData(strPoint,intPoint,num); 
  
  return 0;
  }
  
  void initializeData(string *names[], int *scores[], int num)
  {
          for(int i=0;i&lt;num;i++)
          {
                  cout &lt;&lt; "Please input the name for score: " &lt;&lt; i+1 &lt;&lt; ": " &lt;&lt; endl;
                  cin &gt;&gt; *(names[i]);   
                  cout &lt;&lt; "Please input the score for player: " &lt;&lt; i+1 &lt;&lt; ": " &lt;&lt; endl;
                  cin &gt;&gt; *(scores[i]);
          }
  }
  
  void sortData(string *names[], int *scores[], int num)
  {
   int minIndex,minValue,x;
   string stringTemp;
  
               for(int i = 0;i&lt;(num-1);i++)
               {
                  minIndex = i;
                  minValue = *(scores[i]);
  
                  for(x= i+1;x&lt;num;x++)
                  {
                          if(*(scores[x]) &gt; minValue)   
                           {
                            minValue = *(scores[x]);
                            minIndex = x;
                           }
                  }
  
                  *(scores[minIndex])=*(scores[i]);
                  *(scores[i]) = minValue;
  
                  stringTemp = *(names[minIndex]);
                  *(names[minIndex]) = *(names[i]);
                  *(names[i]) = stringTemp;
          }
  }
  
  void displayData(string *names[], int *scores[], int num)
  {
  cout &lt;&lt; "Top scorers: " &lt;&lt; endl;
           for(int i=0;i&lt;num;i++)
          {
                  cout &lt;&lt; names[i] &lt;&lt;": ";
                  cout &lt;&lt; scores[i] &lt;&lt; endl;
          }
  }
  </code></pre>
  
  <p>and my current output:
  How many scores would you like to enter?: 10
  Segmentation fault (core dumped)</p>
  
  <p>which happens regardless of what int i put there. I put a cout statement after the 
  cin &lt;&lt; num; to see if the program got that far but it never does.</p>
  
  <p>Any help is greatly appreciated. Sorry if this is the most basic error ever.</p>