title: Pointer to string array in C
body: <p>Playing with pointers in <code>C</code> is fun (not really).</p>
  
  <p>I have several arrays of strings I want to declare in an easy way, preferably something like:</p>
  
  <pre><code>arrayOfStrings1 = {"word1", "word2", etc. };
  arrayOfStrings2 = {"anotherword1", "anotherword2", etc. };
  arrayOfStrings3 = etc.
  etc.
  </code></pre>
  
  <p>Something similar to a translation array (but not quite), so I want to be able to swap between these during runtime. For that I want a pointer <code>pointerToArrayOfStrings</code> that I can swap like:</p>
  
  <pre><code>pointerToArrayOfStrings = arrayOfStrings1;
  doStuff();
  pointerToArrayOfStrings = arrayOfStrings2;
  doSomeOtherStuff();
  </code></pre>
  
  <p>In my naive understanding of arrays of strings and pointers to these, this is what I tried:</p>
  
  <pre><code>// Danish transforms
  const unsigned char* da_DK[] = {"b","bb","c","c","cc","d","dd","e","f","ff","g","gg","h","hh","j","j","jj","k","k","kk","l","l","l","l","ll","m","mm","n","n","nn","p","pp","r","r","r","rr","s","s","s","ss","t","t","tt","v","v","vv","æ"};
  
  // British english transforms
  const unsigned char* en_GB[] = {"a","a","a","a","a","a","a","a","a","a","a","a","a","age","ai","aj","ay","b","cial","cian","cian","dj","dsj","ea","ee","ege","ei","ei","eigh","eigh","f","f","f","g","g","gs","i","i","i","j","j","k","ks","kw","l","m","n","n","o","r","s","s","sd","sdr","sion","sion","sj","sj","tial","tion","tion","tj","u","u","u","u","w","ye","ye","z"};
  
      // More languages....
  
  const unsigned char** laguageStrings;
  
  // Assign language
  if (streq(language, "da-DK")){
      laguageStrings= da_DK;
  }
  else if (streq(language, "en-GB")){
      laguageStrings= en_GB;
  }
  else
           return 0;
  }
  </code></pre>
  
  <p>Language is a <code>char *</code> containing the language "en-GB", "da-DK" etc., <code>streq()</code> is just a home brewed (somewhat faster than <code>strcmp()</code>) string comparison function.</p>
  
  <p>Long story short, depending on compiler this approach may work, report compiler warnings or compile, but give unexpected results.</p>
  
  <p>What would be the correct way to solve this problem?</p>