Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // #include "stdafx.h" crap not needed
- #include <stdio.h>
- #include <string.h>
- // #include <conio.h> crap not needed
- #include <stdlib.h>
- #define NO_OF_STUDENTS 4 // too lazy for 20
- struct data {
- char name[20];
- int age;
- int weight;
- };
- int main()
- {
- struct data Students[NO_OF_STUDENTS]; // 20 students.
- int Counter = 0;
- for (Counter = 0; Counter < NO_OF_STUDENTS; ++Counter) {
- scanf("%s", Students[Counter].name); //what about "[Counter"] after name??
- scanf("%d", &Students[Counter].age);
- scanf("%d", &Students[Counter].weight);
- }
- for (Counter = 0; Counter < NO_OF_STUDENTS; ++Counter) {
- printf("Name=%s, ", Students[Counter].name);
- printf("Age=%d, ", Students[Counter].age);
- printf("Weight=%d\n", Students[Counter].weight);
- }
- qsort (Students[20].age,20, sizeof(int), compare); // i dont know what do with this
- system("pause");
- return 0;
- }
- int compare (const void * a, const void * b)
- {
- return ( *(int*)a - *(int*)b );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement