-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfinal struct sorusu.c
More file actions
66 lines (51 loc) · 935 Bytes
/
final struct sorusu.c
File metadata and controls
66 lines (51 loc) · 935 Bytes
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<stdio.h>
#include<stdlib.h>
struct TEST{
int ID;
char Hash[32];
};
struct TEST * dondur(struct TEST *ar,int n){
int i,j;
int m=0;
struct TEST *dizi2;
for (i=0;i<n;i++){
if(ar[i].ID==0){
m++;
}
}
dizi2=(struct TEST*)malloc (m*sizeof(struct TEST));
if(dizi2==NULL){
printf("can not allocate\n");
return NULL;
}
j=0;
for (i=0;i<n;i++){
if(ar[i].ID==0){
dizi2[j]=ar[i];
j++;
}
}
/* for(i=0;i<m;i++){
printf("%d", dizi2[i].ID);
printf("%s", dizi2[i].Hash);
}*/
return dizi2;
}
int main(){
struct TEST dizi[10];
struct TEST *array;
int i,n;
printf("n=?\n");
scanf("%d",&n);
for(i=0;i<n;i++){
printf("%d gir:\n",i);
scanf("%d", &dizi[i].ID);
scanf("%s", dizi[i].Hash);
}
array=dondur(dizi,n);
for(i=0;i<2;i++){
printf("%d", array[i].ID);
printf("%s", array[i].Hash);
}
return 0;
}