I have the following example code in which I try to insert a structure into another, but then I do not know how to access its fields.
#include <stdio.h>
#include <stdlib.h>
typedef struct Ejemplo{
void* data;
} ejemplo;
typedef struct Dentro{
char* dataDentro;
} dentro;
int main(){
char nombre[] = "Cris#include <stdio.h>
#include <stdlib.h>
typedef struct Ejemplo{
void* data;
} ejemplo;
typedef struct Dentro{
char* dataDentro;
} dentro;
int main(){
char nombre[] = "Cris%pre%";
ejemplo* estructura = malloc(sizeof(ejemplo));
dentro* estructuraInterior = malloc(sizeof(dentro));
estructuraInterior->dataDentro = nombre;
estructura->data = estructuraInterior;
printf("\n%s\n ", estructura->data->dataDentro);
return 0;
}
";
ejemplo* estructura = malloc(sizeof(ejemplo));
dentro* estructuraInterior = malloc(sizeof(dentro));
estructuraInterior->dataDentro = nombre;
estructura->data = estructuraInterior;
printf("\n%s\n ", estructura->data->dataDentro);
return 0;
}
This does not work and produces an error in the printf line
error: member reference base type 'void' is not a structure or union
How should this be done to make it work?