title: C segmentation fault when printing different things
body: <p>I am currently making a few functions for a school project. When running each function alone and printing them, I have no errors, however when I print the result of all of the functions in main, I get a segmentation fault for the last function output.</p>
  <p>My source code can be found <a href="https://github.com/danzam284/C-error-file/blob/main/hw1.c" rel="nofollow noreferrer">Here</a>. This is the main segment which is not working:</p>
  <pre><code>int main() {
      char str1[] = &quot;382 is the best!&quot;;
      char str2[100] = {0};
  
      strcpy(str1, str2);
      puts(str1);
      puts(str2);
  
      int vec_a[3] = {12,34,10};
      int vec_b[3] = {10,20,30};
      int dot = dot_prod((char*) vec_a, (char*) vec_b, 3, sizeof(int));
      printf(&quot;%d\n&quot;, dot);
      int arr[3] = {0x12BFDA09, 0x9089CDBA, 0x56788910};
      sort_nib(arr, 3);
      for (int i = 0; i &lt; 3; i++) {
          printf(&quot;0x%08x &quot;, arr[i]);
      }
  
      printf(&quot;\n&quot;);
      return 0;
  }
  </code></pre>
  <p>When running this code segment, I get the correct output for all except the final print loop, which I get a segmentation fault. However, if I comment out the puts statements and the printf(dot), the final print loop works.</p>
  <p>Any help is greatly appreciated</p>