comunque eco un esempio di codice
- Codice: Seleziona tutto
#include <stdio.h>
#include <stdlib.h>
#define N 5
typedef struct obj_s
{
int pappa;
char *mamma;
}obj;
void free_with_void(void **eraser, int N);
void free_all(obj **struttura, int **monello, int N);
int main()
{
obj **struttura;
int **monello, i;
void **eraser;
struttura=(obj **)malloc(sizeof(obj *)*N);
for(i=0;i<N;i++)
struttura[i]=(obj *)malloc(sizeof(obj)*N);
monello=(int **)malloc(sizeof(int *)*N);
for(i=0;i<N;i++)
monello[i]=(int *)malloc(sizeof(int)*N);
free_all(struttura, monello, N);
eraser=struttura;
free_with_void(eraser, N);
eraser=monello;
free_with_void(eraser, N);
return EXIT_SUCCESS;
}
void free_with_void(void **eraser, int N)
{
int i;
for(i=0;i<N;i++)
free(eraser[i]);
free(eraser);
}
void free_all(obj **struttura, int **monello, int N)
{
int i;
for(i=0;i<N;i++)
{
free(struttura[i]);
free(monello[i]);
}
free(struttura);
free(monello);
}
io vorrei evitare la free_all (anche se elegante) per usare la free_with_void, per capire i puntatori a void (che sono molto utili con ADT di tipo 1)
PS e OT alla linea 11 e 12 mi da questo errore
- Codice: Seleziona tutto
error: expected ';', ',' or ')' before numeric constant
che non capisco cosa sia!



