title: Getting Bus error: 10 when looping through a string array
body: <p>I initialized 2 arrays of strings which I believe is <code>{NULL, NULL, NULL}</code> I am trying to iterate through the array <code>variableName</code> and check is a certain string exists e.g. "hello". It doesn't exist in this case so I expect it to print <code>"not found"</code> but instead I get a Bus error: 10</p>
  
  <pre><code>char variableName[3][20];
  char variableValue[3][20];
  
  void addVar(char name[], char value[]) {
  
      if (varDeclared(name, variableName) == 1) {
  
          printf("exists");
          int index = getIndex(name, variableName);
          changeVal(value, variableValue, index);
  
      }
      else {
          printf("not found");
      }
  }
  
  int varDeclared(char name[], char variableName[][20]) {
  
      int i = 0;
  
      while(variableName[i]) {
          if (strcmp(name, variableName[i]) == 0) {
              return 1;
              break;
          }
          i++;
      }
      return 0;
  }
  
  int getIndex(char name[], char variableName[][20]) {
  
      int i = 0;
  
      while(variableName[i]) {
          if (strcmp(name, variableName[i]) == 0) {
              return i;
              break;
          }
          i++;
      }
      return 0;
  }
  </code></pre>