I would like to know how I could copy the contents of a linked list into a text file created at runtime.
I have this part of the code but it does not work:
printf("Nombre de fichero destino: ");
scanf("%s", copia);
if ((fp = fopen (copia, "w")) == NULL ){
printf("ERROR. NO se puede crear el fichero destino %s\n", copia);
printf("\n\n");
system("pause");
return 1; /* Salimos de la funcion main. Terminamos el programa */
}
while(aux!=NULL){
fputc(aux, copia);
aux = aux->sig;
}
I clarify that aux is a pointer that points to the first element of the list so that it can be traversed element by element.