Título: funcion reconocer emails Publicado por: Dato Vagabundo en 5 Septiembre 2016, 10:43 am Hola buenas,
tengo que hacer una funcion que reconozca emails , he sacado esto. Si alguien me puede ayudar, se lo agradeceria int emails(char *email) { int i; if (email==NULL) return 0; for (i=0; i<email ; i++) { if(email[0]== '@' || email[0]== '.') return 0; if(email!='@') return 0; } return 1; } Título: Re: funcion reconocer emails Publicado por: Dato Vagabundo en 5 Septiembre 2016, 11:30 am he probado con esto tambien,
soy principiante int emails(char *email) { char EMAIL_LEN [50]; char user[EMAIL_LEN]; char site[EMAIL_LEN]; char domain[4]; int i=0; if (email==NULL) return 0; else { for (i=0; i<email[EMAIL_LEN] ; i++) if(email[EMAIL_LEN]=!"%[_a-zA-Z0-9.]@%[_a-zA-Z0-9.]", user, domain){ return 0; } Título: Re: funcion reconocer emails Publicado por: ivancea96 en 5 Septiembre 2016, 16:21 pm EMAIL_LEN es un entero, un tamaño, no un char[50].
int EMAIL_LEN En la condición del for, estás mirando si 'i' es menor que un caracter. Tienes que mirar si 'i' es menor que la longitud del email. for(i=0; i<EMAIL_LEN; i++) A partir de ahí, las comprobaciones que quieras hacer. ´como detalle,m en el segundo código pusiste email[ EMAIL_LEN ]. Será email. Y luego, "=!". Para ver si es diferente, es "!=". Luego, ese regex que pusiste, y esas comas ",user, domain", no tienen sentido aquí. No sñ´´e de qué lenguaje vienes, pero eso no existe en C ni en C++. Título: Re: funcion reconocer emails Publicado por: bengy en 5 Septiembre 2016, 18:08 pm averigua sobre expresiones regulares, con ello se hace mas rapido
Título: Re: funcion reconocer emails Publicado por: Dato Vagabundo en 5 Septiembre 2016, 18:21 pm Gracias!!! por la ayuda
Título: Re: funcion reconocer emails Publicado por: WHK en 5 Septiembre 2016, 18:23 pm Mira: https://www.owasp.org/index.php/OWASP_Validation_Regex_Repository
Código
|