-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab15q1.c
More file actions
70 lines (54 loc) · 991 Bytes
/
Copy pathlab15q1.c
File metadata and controls
70 lines (54 loc) · 991 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
67
68
69
70
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stack_str.h"
int find(char *mail)
{
int i = 0;
while (mail[i]!='@')
{
i++;
}
return i;
}
void display_stack(stack_t stack)
{
printf("STACK CONTENT\n");
info_t remove;
while (!isEmptyS(&stack))
{
remove = pop(&stack);
printf("%s %s %s %s\n",remove.name,remove.surname,remove.phone,remove.email );
}
}
int main()
{
FILE*inp;
inp = fopen("people.txt", "r");
info_t array;
int i = 0;
int index;
char temp[20] = "";
stack_t stack;
initializeS(&stack);
if (inp == NULL)
{
printf("ERROR");
}
else
{
for ( i = 0; i < 7; i++)
{
fscanf(inp, "%s %s %s %s", array.name, array.surname, array.phone, array.email);
index = find(array.email);//we
strncpy(temp, array.email+index+1 , 5);
temp[6] = '\0';//the content is 'gmail'
if (strcmp(temp,"gmail")==0)
{
push(&stack, array);
}
}
}
display_stack(stack);
system("PAUSE");
}