-
Notifications
You must be signed in to change notification settings - Fork 0
/
pilaPrestamosInactivos.c
71 lines (56 loc) · 1.54 KB
/
pilaPrestamosInactivos.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include <stdlib.h>
#include "pilaPrestamosInactivos.h"
#define ARCHIVO_PRESTAMOS_INACTIVOS "archivoPrestamosInactivos.bin"
void inicPila(pilaPrestamos * pila)
{
pila->prestamoInactivo = inicListaDoble();
}
void archivoAPila(pilaPrestamos * pila)
{
stPrestamo aux;
FILE * buffer = fopen(ARCHIVO_PRESTAMOS_INACTIVOS,"rb");
if(buffer != NULL)
{
while(fread(&aux,sizeof(stPrestamo),1,buffer)>0)
{
pila->prestamoInactivo = agregarAlPpioDoble(pila->prestamoInactivo,crearNodoDoble(aux));
}
}
else
{
imprimirMensajeRojo("Archivo prestamos vacio");
}
}
void apilar(pilaPrestamos * pila,stPrestamo aux)
{
//mostrarUnPrestamo(aux);
pila->prestamoInactivo = agregarAlPpioDoble(pila->prestamoInactivo,crearNodoDoble(aux));
}
void mostrarPila(pilaPrestamos pila)
{
if(pila.prestamoInactivo != NULL)
{
mostrarListaDoble(pila.prestamoInactivo);
}
else
{
imprimirMensajeRojo("Pila vacia");
}
}
void cargarPilaAlArchivo(pilaPrestamos * pila)
{
FILE * buffer = fopen(ARCHIVO_PRESTAMOS_INACTIVOS,"wb");
if(buffer != NULL)
{
while(pila->prestamoInactivo != NULL)
{
fwrite(&pila->prestamoInactivo->datoPrestamo,sizeof(stPrestamo),1,buffer);
pila->prestamoInactivo = pila->prestamoInactivo->siguiente;
}
}
else
{
imprimirMensajeRojo("Archivo de prestamos inactivos vacio");
}
}