title: To display year in sorted order through array of structures
body: <p>My question is to make a structure containing three members i.e. day , month and year and we have to supply year of joining of 10 employees through keyboard. The year supplied should be displayed back to the user in increasing order of the year ?</p>
  
  <p>So i have used array of structures and then supplied the values using scanf() function and later i have make use of bubble sort to sort the year supplied . But it seems that i am having problem in scanf() . I am facing run-time error in my code . What's the mistake in my code . Please Help.</p>
  
  <p>Below is my code</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  void swap(int *, int *);
  int main()
  {
  int i, j;
  
  typedef struct date
  {
      char day : 5;
  
      char month : 4;
  
      int year : 12;
  
  }D;
  
  D arr[10];
  
  printf("Enter year of joining of 10 employees\n");
  
  for (i = 0; i &lt; 10; i++)
      scanf_s("%d", arr[i].year);
  
  for (i = 0; i &lt; 10; i++)
  {
      for (j = i + 1; j &lt; 10; j++)
      {
          if (arr[i].year &gt; arr[j].year)
              swap(arr[i].year, arr[j].year);
  
      }
  
  }
  
  printf("Value of employees joining year in sorted order is : \n");
  
  for (i = 0; i &lt; 10; i++)
      printf("%d", arr[i].year);
  
  return 0;
  
  }
  
  void swap(int *x, int *y)
   {
    int temp;
  
    temp = *x;
    *x = *y;
    *y = temp;
  
    }
  </code></pre>