title: Candidate Function to Print Generic Array in C
body: <p>Greeting,</p>
  
  <p>Level: between beginner to intermediate</p>
  
  <p>Here is my candidate array printing function I have:</p>
  
  <pre><code>void print_array(void * arr, int len, size_t size) {
  
      if (size == sizeof(int)) {
          int i;
          for (i = 0; i &lt; len - 1; i ++) {
              printf("%d, ", ((int *) arr)[i]);
          }
          printf("%d\n", ((int *) arr)[i]);
      } else if (size == sizeof(double)) {
          ...
      } ...
  
  }
  </code></pre>
  
  <p>I am trying to make it platform independent. It works fine for my project. I am wondering what kind of problems this function would produce if it were included within the standard C libraries. And also, why is there no array printing function within the C libraries?</p>
  
  <p>Thanks.</p>