Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Check email addresses*/
- #include <stdio.h>
- #include <stdlib.h>
- void usage(char *app)
- {
- printf("usage %s <email> [email]", app);
- }
- int process(int argc, char *argv[])
- {
- char *email = argv[1];
- int darabkukac=0, pontdarab=0;
- char *p, *q;
- p = email;
- if (p == NULL)
- return EXIT_FAILURE;
- q = email;
- if (q == NULL)
- return EXIT_FAILURE;
- while (*p != '\0')
- {
- if ((*p) == '@')
- darabkukac++;
- p = p++;
- }
- while (*q != '\0')
- {
- if ((*q) == '.')
- pontdarab++;
- q = q++;
- }
- if ((darabkukac == 1) && (pontdarab >= 1))
- printf("The email is correct.\n");
- else
- printf("The email is incorrect.\n");
- return EXIT_SUCCESS;
- }
- int main(int argc, char *argv[])
- {
- if (argc == 1)
- {
- usage(argv[0]);
- return EXIT_SUCCESS;
- }
- return process(argc, argv);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement