Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #define MAXC 25+1
- typedef struct
- {
- int ore;
- char codice[6], *nome, *cognome, *categoria, nascita[11];
- }atleti;
- typedef struct nodo *link;
- typedef struct
- {
- atleti atl;
- link next;
- }Lista;
- int leggiFile(link *head,link *tail);
- void inserimento_in_coda(link *head,link *tail,atleti val);
- link nuovo_nodo(atleti val,link next);
- int main()
- {
- int scelta, continua, N;
- link head,tail;
- N= leggiFile(&head,&tail);
- return 0;
- }
- int leggiFile(link *head,link *tail)
- {
- int i,N;
- char buf[MAXC];
- FILE *atl;
- atleti val;
- link x;
- if((atl=fopen("atleti.txt", "r"))==NULL)
- {
- printf("ERRORE APERTURA FILE");
- exit(EXIT_FAILURE);
- }
- fscanf(atl, "%d", &N);
- for(i=0; i<N; i++)
- {
- fscanf(atl, "%s %s", val.codice, buf);
- val.cognome= strdup(buf);
- fscanf(atl, "%s", buf);
- val.nome= strdup(buf);
- fscanf(atl, "%s", buf);
- val.categoria= strdup(buf);
- fscanf(atl, "%s %d", val.nascita,&val.ore);
- }
- inserimento_in_coda(head,tail,val);
- return N;
- }
- void inserimento_in_coda(link *head,link *tail,atleti val)
- {
- if(*head==NULL) {
- *head=*tail=nuovo_nodo(val,NULL);
- } else {
- (*tail)->next=nuovo_nodo(val,NULL);
- *tail=(*tail)->next;
- }
- }
- link nuovo_nodo(atleti val,link next)
- {
- link x;
- x=(link)malloc(sizeof(Lista));
- if(x!=NULL) {
- x->atleti=val;
- x->next=next;
- }
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement