-
Notifications
You must be signed in to change notification settings - Fork 0
/
testAREA.c
executable file
·91 lines (83 loc) · 2.02 KB
/
testAREA.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#if 0
gcc -o ${0}.out $0 -lm && ${0}.out
rm -f *.out
exit ${?}
#endif
// wap to store array of integers in a file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct leaves
{
char id[50];
int lv[12][5];
};
struct employe
{
char id[100];
char name[100];
char dob[100];
char phone[100];
char email[100];
char password[100];
char type[100];
int leaves;
long int doj;
};
int main()
{
struct leaves var;
FILE *fp, *fp1;
struct employe e;
int i, j;
fp = fopen("array.txt", "a");
if (fp == NULL)
{
printf("Error opening file");
exit(1);
}
strcpy(var.id, "1658582969d");
for (i = 0; i < 12; i++)
{
for (j = 0; j < 10; j++)
{
var.lv[i][j] = i * j;
}
}
fwrite(&var, sizeof(var), 1, fp);
fclose(fp);
fp1 = fopen("user.txt", "r");
if (fp == NULL)
{
printf("Error opening file");
exit(1);
}
while (fscanf(fp1, "%s %s %s %s %s %s %s %d %ld", e.id, e.name, e.dob, e.phone, e.email, e.password, e.type, &e.leaves, &e.doj) != EOF)
{
fp = fopen("array.txt", "r");
while (fread(&var, sizeof(var), 1, fp) != 0)
{
if (strcmp(e.id, var.id) == 0)
{
printf("%s %s %s %s %s %s %s %d %ld\n", e.id, e.name, e.dob, e.phone, e.email, e.password, e.type, e.leaves, e.doj);
}
}
fclose(fp);
}
fclose(fp1);
return 0;
}
/*
else if ((l1.day[current_month][0][0] == i ||
l1.day[current_month][1][0] == i ||
l1.day[current_month][2][0]== i ||
l1.day[current_month][3][0] == i ||
l1.day[current_month][4][0]== i)&&
(l1.day[current_month][0][1] == 1||
l1.day[current_month][1][1] == 1||
l1.day[current_month][2][1]== 1||
l1.day[current_month][3][1] == 1 ||
l1.day[current_month][4][1]== 1))
{
printf("\033[38;2;255;30;30m\033[%d;%dH%d \x1b[0m", placex, placey + 5 * tick, i);
}*/