View difference between Paste ID: rykwmjHc and 3bhsxSEy
SHOW: | | - or go back to the newest paste.
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;
15
    int weight;
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
 for(; Counter < NO_OF_STUDENTS; ++Counter)
28
    {
29
Students[Counter].name[NO_OF_STUDENTS] = '\0'
30-
scanf("%s", Students[Counter].name);
30+
scanf("%s", Students[Counter].name[Counter]);
31
scanf("%d", Students[Counter].age);
32
scanf("%d", Students[Counter].weight);
33
}
34
 
35
    qsort (Students[20].age,20, sizeof(int), compare); // i dont know what do with this
36
 
37
 
38
    for (n=0; n<NO_OF_STUDENTS; n++)
39
        printf ("%d ",values[NO_OF_STUDENTS]);
40
    return 0;
41
}
42
 
43
 
44
int compare (const void * a, const void * b)
45
{
46
    return ( *(int*)a - *(int*)b );
47
}