title: How can I map a character to a pointer of another type?
body: <p>I have a <code>char*</code>. I want to parse it, character by character, and store the location of each in an <code>int*</code>.</p>
  
  <p>With the dummy-string "abbcdc", the content should be as follows</p>
  
  <pre><code>char       int*
  -------------
  'a'     -&gt; 0
  'b'     -&gt; 1,2
  'c'     -&gt; 3,5
  'd'     -&gt; 4
  </code></pre>
  
  <p>I want this to be accessible through a <code>char*</code> containing the entire alphabet, so that each character in the alphabet-pointer points to each separate integer-pointer. This is where I'm lost.</p>
  
  <p>I know I can point to a pointer using the double-asterisk syntax</p>
  
  <pre><code>int **a = &amp;aLocations;
  </code></pre>
  
  <p>But I don't really know how to refer to the locations-pointer by using a character as a reference. I am pretty new to C, so all pointers (pun intended) are appreciated.</p>
  
  <p><strong>Update 1:</strong></p>
  
  <pre><code>int *aLocations = malloc(3*sizeof(int));
  aLocations[0] = 13;
  aLocations[1] = 9;
  aLocations[2] = 57;
  
  int **a = &amp;aLocations;
  </code></pre>
  
  <p>This seems to work as expected, but <code>a</code> obviously remains an integer, not a char. I was thinking of writing a function something along the lines of </p>
  
  <pre><code>int *getCharLocations(char c) {
    // returns a pointer to the stored character locations
  }
  </code></pre>
  
  <p>but I don't know how to proceed with implementing it.</p>