-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathten.c
46 lines (38 loc) · 978 Bytes
/
ten.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
#include <stdio.h>
#include <stdlib.h>
struct Student {
int id;
char name[16];
char surname[16];
int average;
};
int main() {
FILE* file = fopen("Ogrenciler.dat", "rb");
if (file == NULL) {
printf("dosya acilamiyor.\n");
return 1;
}
// id gerin
int searchId;
printf("Arama yapilacak ogrenci id : ");
scanf("%d", &searchId);
struct data data;
int found = 0;
while (fread(&data, sizeof(struct data), 1, file) == 1) {
if (student.id == searchId) {
printf("----------------------------\n");
printf("ID : %d\n", data.id);
printf("Name : %s\n", data.name);
printf("Surname : %s\n", data.surname);
printf("Average : %d\n", data.average);
found = 1;
break;
}
}
if (!found) {
printf("kimlikli ogrenci %d bulunamadi.\n", searchId);
}
fclose(file);
return 0;
}