All pastes #819333 Raw Edit

Tribun

public c v1 · immutable
·published 2007-12-16 22:13 UTC
rendered paste body
void	empiler(pile *p, void *val){	pile ne = malloc(sizeof(element) *1);	if ( ne != NULL )	{		ne->val = val;		ne->precedent = *p;		*p = ne;	}}/******/int	main(int argc, char **argv){	char *path = NULL;	DIR *rep = NULL;		struct dirent *lecture;	pile	fichiers;	if ( argc < 2 )	{		puts("Pas assez d'arguments.");		return EXIT_FAILURE;	}	fichiers = creer_pile();	if ( (path = (char *) malloc(sizeof(char) * strlen(argv[1]))) == NULL )	{		puts("Pas assez de mémoire.");		return EXIT_FAILURE;	}	strcpy(path, argv[1]);	rep = opendir(path);	while ( (lecture = readdir(rep)) )	{		printf("Fichier : %s\n", lecture->d_name);		empiler(&fichiers, lecture->d_name);	}			free(path);	closedir(rep);	free(lecture);	vider(&fichiers);	return EXIT_SUCCESS;}