title: Calling functions with arrays?
body: <p>I have some work with this code and i need a swap function that can get a arrays like a[j].</p>
  
  <p>How I need to transport to another function something like this?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  void bubble_sort(int *a, int n) {
    int i, j;
    for (i = 0; i &lt; n; i++) {
      for (j = 0; j &lt; n - i - 1; j++) {
        if (a[j] &gt; a[j + 1]) swap(&amp;a[j], &amp;a[j + 1]);
      }
    }
  }
  </code></pre>
  
  <p>This is the code, so how I can call swap function with a[j]? Do I need to call function like this or?</p>
  
  <pre><code>int swap (int a[],int b[])
  int swap (int *a,int *b)
  </code></pre>
  
  <p>With this second call i am sure that it will work Am i right ? But how can i call this function like the first example?</p>
  
  <pre><code>#define MAX 100
  #include &lt;stdio.h&gt;
  
  void swap(int *a, int *b) {
      int temp = *a;
      *a = *b;
      *b = temp;
      return 0;
  }
  
  void bubble_sort(int a[], int n) {
      int i;
      for(i=0;i&lt;n;i++)
      {
          if(a[i]&lt;a[i+1])
          swap(a[i],a[i+1]);
      }
      return 0;
  }
  
  int main()
  {
      int a[4]={1,2,3,0};
      int n=4;
      bubble_sort(a,n);
      for(int i=0;i&lt;n;i++)
      {
          printf("%d",a[i]);
      }
  }
  </code></pre>
  
  <p>I used that code Segmentation fault (core dumped)</p>