Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * teste.c
- *
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void funcion_2(const char *);
- int function_1(const char *);
- void funcion_2(const char *arquivo){
- function_1(arquivo);
- }
- int function_1(const char *arquivo){
- FILE *fp;
- char* linha;
- fp = fopen (arquivo, "r");
- if (fp == NULL) {
- printf ("Houve um erro ao abrir o arquivo.\n");
- return 1;
- }
- while( fgets(linha, 1024, fp) ){
- printf( "Nome: %s\n", strtok(linha, ";"));
- printf( "Mail: %s\n", strtok(NULL , ";"));
- }
- fclose(fp);
- return 0;
- }
- int main()
- {
- funcion_2("/tmp/mail.txt");
- function_1("/tmp/mail.txt");
- exit(0);
- }
- /*** FIM teste.c ***/
- /* mail.txt */
- Maria da Silva;maria@email.com.br
- Joao Abrantes;joao@email.com.br
- Nelson Jobin;nelson@email.com.br
- Jose Sarney;jose@email.com.br
- Adriano de Souza;adriano@email.com.br
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement