title: C function to return a char array generated with strcat in a for loop
body: <p>I am trying to add 10 strings containing the word "data" in a char array and return the result.  Here is my code:</p>
  
  <pre><code>    #include &lt;stdio.h&gt;
      #include &lt;string.h&gt;
  
      char* concat () {
         char src[50], dest[1];
         strcpy(src,  "data");
  
         int i =0;
         for (i=0; i&lt;=10; i++) {
            strcat(dest, src);
            strcat(dest, ",");
         }
         return(dest);
      }
  
      int main () {
          printf("Final destination string : |%s|", concat());
          return 0;
      }
  </code></pre>
  
  <p>But when I return my <code>dest</code> char array I get a segmentation fault.</p>