title: C Pointers revisited
body: <p>I learning to use Pointers.<br>
  I have a few questions about an exercise code I wrote.</p>
  
  <p>First, if I have the following function code:</p>
  
  <pre><code>//function prototype
  void processCars(char *, char []);
  
  int main(){
  ...
  //actual callto the function
  processCars(strModel[x], answer);
  ...
  }
  
  void processCars(char * string1, char string2[])
  {
  ...
  }
  </code></pre>
  
  <p>How would it be correct the define the arguments of this processCars function?
  The first one - char * - is a pointer to char, which is the start location of the string (or better an array of chars) ?
  The second is actually an array of chars directly.</p>
  
  <p>Now, supposed I want to pass by reference a few array of strings and even array of structs. I managed to create the following code which works, but I still don't fully get what I'm doing.
  </p>
  
  <pre><code>typedef struct car {
  
      char make[10];
      char model[10];
      int year;
      int miles;
  
  } aCar; // end type
  
  // function prototype
  void processCars( aCar * , char **, char **, int *, int *);
  
  //aCar * - a pointer to struct of type car 
  //char **, char ** 
  // int * - a pointer to integer
  //  Arrays passed as arguments are passed by reference.
  // so this prototype works to
  //void processCars( aCar * , char **, char **, int [], int []);
  
  
  int main(){
  
      aCar myCars[3]; // an array of 3 cars
  
      char *strMakes[3]={"VW","Porsche","Audi"}; // array of 3 pointers?
      char *strModel[3]={"Golf GTI","Carrera","TT"};
      int intYears[3]={2009,2008,2010};
      int intMilage[3]={8889,24367,5982};
  
      // processCars(myCars, strMakes);
      processCars(myCars, strMakes, strModel, intYears, intMilage);
  
  return 0;
  } // end main
  
  //  char ** strMakes is a pointer to array of pointers ?
  void processCars( aCar * myCars, char ** strMakes, \
                    char ** strModel, int * intYears, \
                    int * intMilage ){
  }
  </code></pre>
  
  <p>So, my qeustion is how to define this  "char ** strMakes". What is it, why is it working for me?</p>
  
  <p>I have also noticed, I can't change part of the string, because if I correct (or the references I read) 
  strings are read only. So, like in python, I can use array indices to access the letter V:</p>
  
  <pre><code>printf("\n%c",strMakes[0][0]); 
  </code></pre>
  
  <p>But, unlike in python, I can't change it:</p>
  
  <pre><code>strMakes[0][0]="G" // will not work? or is there a way I could not think of?
  </code></pre>
  
  <p>So, thanks for reading through my long post and many question about pointers and c strings. Your answers are appreciated.</p>