Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. /*Check email addresses*/
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. void usage(char *app)
  7. {
  8.     printf("usage %s <email> [email]", app);
  9. }
  10.  
  11. int process(int argc, char *argv[])
  12. {
  13.     char *email = argv[1];
  14.     int darabkukac=0, pontdarab=0;
  15.     char *p, *q;
  16.     p = email;
  17.     if (p == NULL)
  18.         return EXIT_FAILURE;
  19.     q = email;
  20.     if (q == NULL)
  21.         return EXIT_FAILURE;
  22.  
  23.     while (*p != '\0')
  24.     {
  25.         if ((*p) == '@')
  26.             darabkukac++;
  27.         p = p++;
  28.     }
  29.  
  30.     while (*q != '\0')
  31.     {
  32.         if ((*q) == '.')
  33.             pontdarab++;
  34.         q = q++;
  35.     }
  36.     if ((darabkukac == 1) && (pontdarab >= 1))
  37.         printf("The email is correct.\n");
  38.     else
  39.         printf("The email is incorrect.\n");
  40.        
  41.         return EXIT_SUCCESS;
  42. }
  43.  
  44.  
  45. int main(int argc, char *argv[])
  46. {
  47.     if (argc == 1)
  48.     {
  49.         usage(argv[0]);
  50.         return EXIT_SUCCESS;
  51.     }
  52.     return process(argc, argv);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement