Guest User

Untitled

a guest
Apr 20th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.34 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <conio.h>
  5. #include <stdlib.h>
  6.  
  7.  
  8. #define NO_OF_STUDENTS 20
  9.  
  10.  
  11. struct data
  12. {
  13.     char name[20];
  14.     int age[20];
  15.     int weight[20];
  16. };
  17.  
  18.  
  19.  
  20.  
  21. int main ()
  22. {
  23.     int n;
  24.     struct data Students[NO_OF_STUDENTS]; // 20 students.
  25.     int Counter = 0;
  26.  
  27.  
  28.     int ager [NO_OF_STUDENTS] = Students[NO_OF_STUDENTS].age[20];
  29.  
  30.  
  31.     for(; Counter < NO_OF_STUDENTS; ++Counter)
  32.     {
  33.         Students[Counter].name[NO_OF_STUDENTS] = '\0'; // Set the end of the string.
  34.         scanf("%s", Students[Counter].name); // Extract 19 characters.
  35.     }
  36.  
  37.  
  38.     for(; Counter < NO_OF_STUDENTS; ++Counter)
  39.     {
  40.         Students[Counter].age[NO_OF_STUDENTS] = '\0'; // Set the end of the string.
  41.         scanf("%d", Students[Counter].age); // Extract 19 characters.
  42.     }
  43.  
  44.  
  45.     for(; Counter < NO_OF_STUDENTS; ++Counter)
  46.     {
  47.         Students[Counter].weight[NO_OF_STUDENTS] = '\0'; // Set the end of the string.
  48.         scanf("%d", Students[Counter].weight);
  49.     }
  50.  
  51.  
  52.  
  53.  
  54.     qsort (Students[20].age,20, sizeof(int), compare); // i dont know what do with this
  55.  
  56.  
  57.     for (n=0; n<NO_OF_STUDENTS; n++)
  58.         printf ("%d ",values[NO_OF_STUDENTS]);
  59.     return 0;
  60. }
  61.  
  62.  
  63. int compare (const void * a, const void * b)
  64. {
  65.     return ( *(int*)a - *(int*)b );
  66. }
Advertisement
Add Comment
Please, Sign In to add comment