title: Bus error (core dumped) error (ubuntu) C program
body: <p>I have a program in which a user inputs how many sentences they want, and then then be prompted to input the sentences. they cannot enter more than ten sentences. when i test, if i enter more than 5, i get a bus error code. here is my code, i am calling two functions in .h files that i dont believe are relevant but i will provide them anyways.  </p>
  
  <pre><code>//this program will take in user input for a number of sentences  up to ten, each with 100 char or less, and convert them all to uppercase
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include "convert.h"
  
  
  int main () {
  
  int i; //increment
  int numberofsentences; //number of sentences
  char **sentence_array; // sentence array
  
  sentence_array = (char **)malloc(numberofsentences*sizeof(char));
  
  printf ("I will take up to ten sentences of up to 100 chars each, and convert them to uppercase, as well as give you stats on them. \n");
  printf ("How many sentences would you like? \n");
  
  scanf ("%d", &amp;numberofsentences);
  fgetc(stdin);
  
  
  //user inputs the sentences based on the number that was provided
  for (i = 0;  i&lt; numberofsentences; i++) {
      sentence_array[i] = (char *)malloc(100 * sizeof(char));
      printf ("Enter sentence :");
      fgets(sentence_array[i], 101, stdin);
      printf ("\n");
        }
  
  //call function that converts all arrays to uppercase
  convertAll(sentence_array, numberofsentences);
  
  printf("Your converted sentences are: \n");
  
  
  //print out every sentence thats converted to uppercase
  for (i = 0; i &lt; numberofsentences; i++){
      //convertSentence(sentence_array[i]);
      printf("%s", sentence_array[i]);
         }
  }
  </code></pre>
  
  <p>and functions.c file</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include "convert.h"
  
  //function to convert char array to uppercase
  void convertSentence(char *sentence){
          int i;
          for (i = 0; i &lt;strlen(sentence); i++){
                  sentence[i] = toupper(sentence[i]);
          }
  }
  
  //function to convert array of all sentences and converts all to upper
  void convertAll(char **sentenceList, int numOfSentences){
          int i;
          for (i = 0; i &lt; numOfSentences; i++){
                  convertSentence(sentenceList[i]);
          }
  }
  </code></pre>
  
  <p>i feel like its something to do with the memory allocation.
  and as a note: i know that scanf and fgets are terrible, but my professor told us to use them so ... thanks for helping</p>