next up previous
Next: Entrées/Sorties Up: Mémento C - shell, Previous: Abréviations de type

Tableaux taille variable

Tableaux taille variable
#include <stdlib.h>
void remplit(int t[],int n)
{
...
}
int main()
{
int *t;
int n;
scanf("%d",&n);
t=malloc(n*sizeof(int));
remplit(t,n);
...
free(t);
}
#include <stdlib.h>
...
data *rep;
...
rep=malloc(n*sizeof(data));
...
n=new_n;
rep=realloc(rep,n*sizeof(data));
...
free(rep);


R.Keriven (Cermics)