title: C Programming - Changing chars of a string array element
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1726350/problem-with-processing-individual-strings-stored-in-an-array-of-pointers-to-mul">Problem with processing individual strings stored in an array of pointers to multiple strings in C</a>  </p>
  </blockquote>
  
  
  
  <p>Ok so I'm trying to change a char of a string to another char in C. The thing is, each string is an element of a 1D array so essentially all together its a 2D array because a string itself is an array of chars. Anyways I have a problem creating code to do this. Is it even possible to do this? Any help is appreciated. </p>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main ()
  { 
  int i, size;
  char **a;
  
  a=(char**)malloc(sizeof(char*));
  
  printf("Enter the size of the array:");
  scanf("%d", &amp;size);
  
  for(i=0;i&lt;size;i++){
   a[i]=(char*)malloc(sizeof(char)*8);
  }
  
  a[3]="Read";
  
  
  while(*(a[3])!='\0'){
   if(*(a[3]) == 'e'){
      *(a[3]) = 'r';
   }
  }
  
   printf("%s\n", a[3]);
  
   system("pause");
   return 0;
  
  }
  </code></pre>