Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- just another simple e-mail parse
- author: Cooler_
- contact: c00f3r [at] gmail [dot] com
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- // return reverse string
- char *strrev(char *str);
- int
- main()
- {
- static char *domain="@gmail.com";
- char *words=(char *)malloc(sizeof(char)*1024);
- char *email=(char *)malloc(sizeof(char)*1024);
- int x=0,z=0;
- domain=strrev(domain);
- // separa uma palavra por linha
- do{
- if(*s==' ')
- {
- words=strrev(words);
- *(words+x)='\n';
- while( *(domain+z)==*(words+z) && z!=strlen(domain))
- z++;
- if(z==strlen(domain))
- email=strrev(words);
- memset(words,1,x);
- x=0;
- z=0;
- } else
- *(words+x)=*s;
- x++;
- s++;
- }while(*s != '\0');
- puts(email);
- free(words);
- free(email);
- return 0;
- }
- // return reverse string
- char
- *strrev(char *str)
- {
- char *p1, *p2;
- if(! str || ! *str)
- return str;
- for(p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
- {
- *p1 ^= *p2;
- *p2 ^= *p1;
- *p1 ^= *p2;
- }
- return str;
- }
Advertisement
Add Comment
Please, Sign In to add comment