Very good guys, I have a dudilla and I do not know how to raise it, I have to import a .txt data file into a structure. The structure is this:
Structure:
typedef struct
{
char nomEditorial[TAM];
int numPagina;
} tRegLibros;
typedef struct
{
char nomRevista[TAM];
int numRevista;
int paginaInicio;
} tRegArticulos;
typedef struct
{
char titulo[TAM];
char autor[TAM];
char idEjemplar[5];
int anioPubli;
int prestado;
char fecha[20];
char fechaDev[20];
char dniSocio[9];
union
uTipo
{
tRegArticulos articulo;
tRegLibros libro;
} uTipo;
} tRegEjemplares;
typedef struct
{
tRegEjemplares ejemplar[maxEJEMPLARES];
int contador;
int contadorLibros;
int contadorArticulo;
} tRegLista;
And the txt data goes like this: * Info in the images
Then I had raised something like that, but I do not know how to approach the problem to see if you can clarify me.
void Importar(tRegLista *reg)
{
char ruta[TAM];
tRegLista aux;
system("cls");
printf("*******************************************************************************\n");
printf(" Importar Ejemplares\n");
printf("*******************************************************************************\n\n\n");
printf("Introduce la ruta del archivo a importar:\n");
fflush(stdin);
gets(ruta);
FILE *fichero;
fichero=fopen(ruta,"r");
if(fichero == NULL)
{
printf("\nERROR: No existe ese fichero\n");
exit(EXIT_FAILURE);
}
fclose(fichero);
}
I add information in the file for example 1 book 1 article one below the other followed and without the title in plan TITLE:, YEAR: the data go directly.