· 8 years ago · Jan 16, 2018, 04:20 PM
1#include <stdio.h>
2#include <string.h>
3
4#define IME 21
5#define PREZIME 31
6#define EMAIL 51
7
8#define MAX_OSOBA 50
9
10typedef struct
11{
12 char ime[IME];
13 char prezime[PREZIME];
14 char email[EMAIL];
15}Osoba;
16
17int gmail(char* s)
18{
19 char* deo = strtok(s, "@");
20 deo = strtok(NULL, "");
21
22 if (strcmp(deo, "gmail.com") == 0)
23 return 1;
24 else
25 return 0;
26}
27
28int main()
29{
30 int n, i;
31 Osoba osobe[MAX_OSOBA];
32
33 printf("Uneti broj osoba: ");
34 scanf("%d", &n);
35
36 if (n < 0 || n >= MAX_OSOBA)
37 {
38 printf("Greska u broju osoba.\n");
39 return -1;
40 }
41
42 printf("Uneti podatke o osobama, ime, prezime i email.\n");
43 for(i=0; i<n; i++)
44 scanf("%s%s%s", osobe[i].ime, osobe[i].prezime, osobe[i].email);
45
46 printf("Vlasnici gmail naloga su:\n");
47 for(i=0; i<n; i++)
48 if (gmail(osobe[i].email))
49 printf("%s %s\n", osobe[i].ime, osobe[i].prezime);
50
51 return 0;
52}