Arquivo .txt , Lista simplesmente encadeada, vetores

0 respostas
V

Boa noite, como eu faço para ler as informações de um arquivo txt, passar para uma lista encadeada que esta organizada em vetores.( o Programa é uma agenda telefonica), onde cada campo do vetor é uma letra do alfabeto.

segue código.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct data{

int dia;

int mes;

int ano;

};

typedef struct data DATA;
struct agenda{

char nome[50];

DATA nascimento;

int telefone;

char email;

struct agenda *prox;

};

typedef struct agenda AGENDA;
struct letra{

char letra;

struct agenda *inicio;

};

typedef struct letra LETRA;

/---------------------------/

void inicialisa_letras(LETRA vetor[26]){

int i;

for(i=0; i<26; i++){

vetor[i].letra = a+i;

vetor[i].inicio= NULL;

}
}

/<em>---------------------------</em>/

void insere (LETRA vetor[26], char nome[50], int dia, int mes, int ano, int telefone, char email[50]){
AGENDA *nodo = (AGENDA*)malloc(sizeof(AGENDA));
strcpy(nodo->nome,nome);
nodo->prox = NULL;

nome[0]=tolower(nome[0]);
 char c = nome[0];
 int pos = c - 'a';

}
/---------------------------/

/<em>---------------------------</em>/

int main(){

LETRA vetor[26];

AGENDA *lista=NULL;

char nome[50], email[50];

int dia, mes, ano , telefone;

int op;
inicialisa_letras(vetor);

system(cls);

printf("\n\n ====MENU==== \n\n");

printf("\n  1-INSERIR CONTATO>>\n");

printf("\n  2-EDITAR CONTATO>>\n");

printf("\n  3-LOCALIZAR CONTATO>>\n");

printf("\n  4-LISTAR TODOS CONTATOS>>\n");

printf("\n  5-LISTAR CONTATO POR LETRA>>\n");

printf("\n  6-REMOVER CONTATO>>\n");

fflush(stdin);

scanf("%d", &op);
switch(op){

    case 1 : printf(" Digite o Nome: \n");
             scanf("%s", nome);
             fflush(stdin);
             printf(" Digite a Data de Nascimento: \n");
             scanf("%d %d %d", &dia, &mes, &ano);
             fflush(stdin);
             printf(" Digite o Telefone: \n");
             scanf("%d", &telefone);
             fflush(stdin);
             printf(" Digite o email: \n");
             scanf("%s", email);
             fflush(stdin);

             /*------função----*/

        while(op!=2);
         break;
}

}

Criado 19 de novembro de 2018
Respostas 0
Participantes 1