How to copy content from a linked list into a text file in C?

0

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.

    
asked by Mario Hernandez 25.05.2017 в 12:17
source

0 answers