Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Avance Pregunta 2 guía 4
#include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> typedef char cadena[256]; typedef struct { char mail[321]; char domain[256]; }domains; // -----------------Prototypes---------------------- void findDomain ( char *mail, char *domain); int compareDomains( const void *, const void * ); void lowerCase( char *); // ---------------Main Program----------------------- int main(void) { domains typeDomain[10000]; char mail[321]; int i = 0; int total; // --------------------------Input---------------------- while ( i < 10000) { scanf("%320s", typeDomain[i].mail); if ( strcmp(typeDomain[i].mail, "FIN") == 0) break; i++; } // -----------------------Process----------------------- total = i; printf("total: %d.\n\n", total); for (i = 0 ; i < total ; i++) { findDomain(typeDomain[i].mail, typeDomain[i].domain); } for (i = 0 ; i < total ; i++) lowerCase(typeDomain[i].domain); for (i = 0 ; i < total ; i++) { //printf("XX\n"); printf("%s\n", typeDomain[i].domain); } /* qsort(typeDomain, total, sizeof(cadena), compareDomains); printf("\nELEMENTOS ORDENADOS\n\n"); for (i = 0 ; i < total ; i++) printf("%s\n", typeDomain[i].domain);*/ return 0; } /* -------------------------Procedimiento findDomain------------------------------- * Propósito: encontrar el dominio de un correo electrónico. Ejemplo: * pedro@hotmail.com, el dominio es: hotmail.com * */ void findDomain ( char *mail, char *domain) { char *pointer; pointer = mail; if ( pointer = strchr(mail, '@') ) strcpy(domain, pointer + 1); } int compareDomains( const void *pivot, const void *element ) { char *ptrPivot = (char *) pivot; char *ptrElement = (char *) element; return strcmp(ptrPivot, ptrElement); } void lowerCase( char *domain) { while ( *domain != '\0') { if ( isupper( *domain ) ) *domain = tolower(*domain); domain ++; } }
run
|
edit
|
history
|
help
0
WrongWay reversible iterator Copyright(C) 2016 Henry Kroll III www.thenerdshow.com
First program.c
-Wall
14th Feb Project
alphabet2 pyramid right
1
back
A_141125_MenorMayor2
Card shuffling and dealing program using structures
1.4 Thread IDs