title: Why is this code giving me segmentation error?
body: <p>I'm new to C, trying to get an user entered array into ascending order and print it. I'm trying to use selection sort for this.My devcpp crashes after accepting 1st input and when I tried to run it on an online c compiler, its giving segmentation error. Can someone tell me why is this happening here? TIA</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  void swap()
  {
      int *x, *y;
      int temp = *x;
      *x = *y;
      *y = temp;
  }
  
  void ss(int A[], int n)
  {
      int i, j, min;
      for(i=0; i&lt;n-1;i++)
      {
          min = i;
          for(j=i+1; j&lt;n; j++)
          {
              if (A[j]&lt; A[min])
              {
                  min = j;
              }
              swap(&amp;A[min], &amp;A[i]);
          }
      }
  }
  
  void print(int A[], int n)
  {
      int i;
      for(i=0; i&lt;n; i++)
      {
          printf("%d",A[i]);
      }
  }
  
  int main()
  {
      int A[4], i, n;
      printf("Enter the elements");
      scanf("%d", &amp;A[i]);
      n=4;
      ss(A,n);    
      printf("Sorted array \n");
      print(A,n);
      return 0;
  
  }
  </code></pre>
  
  <p>I want the user entered array in ascending order.</p>