Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- typedef struct s_cliente{
- char cliente[21];
- }t_cliente;
- typedef struct s_nodo{
- t_cliente info;
- struct s_nodo *next;
- }t_nodo;
- typedef struct s_coda{
- t_nodo *primo;
- t_nodo *ultimo;
- }codaClienti;
- typedef struct s_racc{
- char destinatario[21];
- int ricevuta;
- }t_racc;
- typedef struct nodo{
- t_racc informazione;
- struct nodo *next;
- }nodo, *Lista;
- typedef struct s2{
- char cliente[21];
- int sportello;
- int numero;
- }t_cliente_serviti;
- typedef struct s3{
- t_cliente_serviti info;
- struct s3 *next;
- Lista sottolista;
- }nodoCoda;
- typedef struct Coda{
- nodoCoda *primo;
- nodoCoda *ultimo;
- }Coda;
- //CODA E LISTA INIT
- void InitCoda(codaClienti *c, Coda *pc){
- c->primo=c->ultimo=NULL;
- pc->primo=pc->ultimo=NULL;
- }
- int CodaVuota(codaClienti c){
- return(c.primo==NULL);
- }
- void MakeNullList(Lista *l){
- *l=NULL;
- }
- int EmptyLista(Lista *l){
- return(l==NULL);
- }
- //FUNZIONE CANCELLA
- void cancella(codaClienti *c){
- codaClienti aux;
- if(c->primo!=NULL){
- aux.primo=c->primo;
- c->primo=c->primo->next;
- free(aux.primo);
- }
- }
- //CARICO IN CODA
- void inserisci_in_coda(codaClienti *c, t_cliente elem){
- t_nodo *aux;
- aux=(t_nodo*)malloc(sizeof(t_nodo));
- aux->info=elem;
- aux->next=NULL;
- if(!CodaVuota(*c)){
- c->primo=c->ultimo=aux;
- }
- else{
- c->ultimo->next=aux;
- c->ultimo=aux;
- }
- }
- codaClienti InCoda(codaClienti *c, char file[]){
- t_cliente aux;
- FILE *fp=NULL;
- fp=fopen(file, "r");
- if(fp==NULL){
- printf("Errore apertura file");
- exit(1);
- }
- while(!feof(fp)){
- fscanf(fp, "%s", aux.cliente);
- inserisci_in_coda(c, aux);
- }
- return *c;
- }
- //STAMPA
- void stampa(codaClienti c){
- t_cliente aux;
- if(c.primo!=NULL){
- printf("/// %s ///", aux.cliente);
- c.primo=c.primo->next;
- }
- }
- //MENU
- int menu(){
- int scelta=0;
- printf("Premi 0 per uscire");
- printf("Premi 1 per inserire in coda");
- printf("Premi 4 per stampare");
- scanf("%d", &scelta);
- return scelta;
- }
- int main(){
- int scelta=0;
- FILE *fp;
- fp=fopen("Clienti.txt", "r");
- t_cliente cliente;
- codaClienti C;
- Lista L;
- Coda Coda;
- do{
- scelta=menu();
- switch(scelta){
- case 1:{
- InCoda(&C, "Clienti.txt");
- break;
- }
- }
- }while(scelta!=0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement