예제 #1
0
파일: test.c 프로젝트: Hexaflou/GreenHub
int main() {
   
	llist ma_liste = NULL; /*Initialisation de la liste*/
    int i=1; /*Variable compteur*/
    char* doubleGmalloc = NULL; /*Pointeurs de test*/
    char * pointeur = NULL ;
   
    printf("\nTest d'allocation simple\n\n");
   
    pointeur = gmalloc(20 * sizeof (char)); 
    
    if (pointeur == NULL) 
	{
        printf("L'allocation n'a pu être réalisée\n");
    } 
    else 
    {
        printf("L'allocation a été un succès\n");
        gfree(pointeur);
    }
    
    printf("\nTest d'allocation liste chainée \n\n");
    

    for(i=1;i<=1000;i++)
    {
        ma_liste = ajouterEnTete(ma_liste, i);
        ma_liste = ajouterEnFin(ma_liste, i);
    }
   
    
    printf("\nOn s'attend à l'affichage de 1000 valeurs croissantes puis 1000 décroissantes\n\n");
    
	afficherListe(ma_liste);
	effacerListe(ma_liste);
  
	printf("\nDouble gmalloc\n\n");
 
	doubleGmalloc=gmalloc(20 * sizeof (char));
	doubleGmalloc="Test malloc 1 \n";
	
	printf("Après gmalloc 1 : pointeur : 0x%x , Valeur : %s\n",*doubleGmalloc,doubleGmalloc);
	
	doubleGmalloc=gmalloc(20 * sizeof (char));
	doubleGmalloc="Test malloc 2 \n";
	
	printf("Après gmalloc 2 : pointeur : 0x%x , Valeur : %s\n",*doubleGmalloc,doubleGmalloc);
 
 
	printf("\nDouble gfree\n\n On s'attend à une segmentation fault !\n\n");
    
    gfree(doubleGmalloc);
    gfree(doubleGmalloc);
    
    
    return 0;
}
예제 #2
0
int main(int argc, char **argv)
{
    llist ma_liste = NULL;
    int i;

    for(i=1;i<=10;i++)
    {
        ma_liste = ajouterEnTete(ma_liste, i);
        ma_liste = ajouterEnFin(ma_liste, i);
    }
    afficherListe(ma_liste);

    ma_liste = effacerListe(ma_liste);

    afficherListe(ma_liste);
    ma_liste = ajouterEnTete(ma_liste, 1);
    afficherListe(ma_liste);
    return 0;
}
예제 #3
0
파일: oc_struct.c 프로젝트: aymerixp/struct
int		main(int argc, char **argv)
{
	(void)argc;
	(void)argv;
	t_element *ma_liste;
	ma_liste = NULL;

	int i;
	i = 1;
	while (i <= 10)
	{
		ma_liste = ajouterEnTete(ma_liste, i);
		ma_liste = ajouterEnFin(ma_liste, i);
		i++;
	}
	afficherListe(ma_liste);
	printf("\n");
	printf("%d", nombreElement(ma_liste));

	return (0);
}