Skip to content

Instantly share code, notes, and snippets.

@enesusta
Last active January 7, 2020 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enesusta/f6c0bdaaa1383c504d2b2f11c2aa467d to your computer and use it in GitHub Desktop.
Save enesusta/f6c0bdaaa1383c504d2b2f11c2aa467d to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Student {
char name[20];
int noteOne;
int noteTwo;
int noteThree;
int noteFour;
int noteFive;
} Student;
void viewAllStudents(struct Student **);
int main() {
struct Student **students = (struct Student**) malloc(50 * sizeof(struct Student)); // 50 ogrencilik alan tahsis ettik
int i;
char buffer[20];
int noteOne,noteTwo,noteThree,noteFour,noteFive;
for ( i = 0; i < 50 ; i++) {
students[i] = (struct Student*) malloc(sizeof(struct Student));
printf("Ogrencinin ismini girin: ");
scanf("%s", &buffer);
strcpy(students[i]->name, buffer);
printf("\nOgrencinin birinci notunu girin: ");
scanf("%d",&noteOne);
students[i]->noteOne=noteOne;
printf("\nOgrencinin ikinci notunu girin: ");
scanf("%d",&noteTwo);
students[i]->noteTwo=noteTwo;
printf("\n Ogrencinin ucuncu notunu girin: ");
scanf("%d",&noteThree);
students[i]->noteThree=noteThree;
printf("\n Ogrencinin dorduncu notunu girin: ");
scanf("%d",&noteFour);
students[i]->noteFour=noteFour;
printf("\n Ogrencinin besinci notunu girin: ");
scanf("%d",&noteFive);
students[i]->noteFive=noteFive;
}
viewAllStudents(students);
free(students);
return 0;
}
void viewAllStudents(struct Student **students) {
int i;
for(i=0;i<50;i++) {
printf("i is :%d\n",i);
printf("Name is : %s\n", students[i]->name);
printf("His note one is : %d\n",students[i]->noteOne);
printf("His note two is : %d\n",students[i]->noteTwo);
printf("His note three is : %d\n",students[i]->noteThree);
printf("His note four is : %d\n",students[i]->noteFour);
printf("His note five is : %d\n",students[i]->noteFive);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment