codice:
#include<stdio.h>
#include<malloc.h>
#include<string.h>
void inserimento(struct elemento *);
void visualizzazione(struct elemento *);
struct elemento
{
char informazione[100];
struct elemento *puntatore;
};
main()
{
struct elemento *lista;
FILE *fp1,*fp2;
char buf1[100],buf2[100];
fp1=fopen("FILE1.txt","w");
fp2=fopen("FILE2.txt","w");
fputs(gets(buf1),fp1);
fputs(gets(buf2),fp2);
fclose(fp1);
fclose(fp2);
inserimento(lista);
}
void inserimento(struct elemento *p)
{
FILE *fp1,*fp2;
char buf1[100],buf2[100];
struct elemento *paus;
p=(struct elemento *)malloc(sizeof(struct elemento));
fp1=fopen("FILE1.txt","r");
fread(buf1,1,100,fp1);
fclose(fp1);
strcpy(p->informazione,buf1);
paus=p;
paus->puntatore=(struct elemento *)malloc(sizeof(struct elemento));
paus=paus->puntatore;
fp2=fopen("FILE2.txt","r");
fread(buf2,1,100,fp2);
fclose(fp2);
strcpy(paus->informazione,buf2);
paus->puntatore=NULL;
visualizzazione(p);
}
void visualizzazione(struct elemento *P)
{
while(P!=NULL)
{
printf("%s\n",P->informazione);
P=P->puntatore;
}
getchar();
}