All pastes #269160 Raw Edit

Divers

public c v1 · immutable
·published 2006-12-06 09:58 UTC
rendered paste body
#include <sys/types.h>#include <stdio.h>#include <dirent.h>#include <stdlib.h>int     order(char **text, int lenght){  char  *tab;  int   i;  int   j;  i = -1;  while ((++i) < lenght)    {      j = -1;      while ((++j) < lenght)          if (strcmp(text[i], text[j]) < 0)            {              tab = text[i];              text[i] = text[j];              text[j] = tab;            }    }  return (0);}/* C'est l'anniversaire de Savory \o/ ~o~ \o_ */int     main(int argc, char **argv){  struct dirent *p;  DIR   *dir;  dir = opendir(*(argv + 1));  int   i;  char  **text;  i = 0;  text = malloc(sizeof(text) * 3000); /* MAYDAY /!\ MALLOC VOMITIF /!\ MAYDAY !*/  if (argc > 1)    {      while ((p = readdir(dir)))          text[i++] = (p -> d_name);      text[i] = '\0';      order(text, i);      for ( i = 0; text[i]; i++)        printf("%s\n", text[i]);    }  return (0);}